0.2.0: Moved into inspector drawer from module.toolbox to module.inspector
This commit is contained in:
parent
5671c2c754
commit
ffec2abdf4
227 changed files with 5306 additions and 29 deletions
40
Editor/Decorators/DrawerHorizontalLine.cs
Normal file
40
Editor/Decorators/DrawerHorizontalLine.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.Inspector.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(HorizontalLine))]
|
||||
public sealed class DrawerHorizontalLine : DecoratorDrawer
|
||||
{
|
||||
private const float LINE_HEIGHT = 1.0f;
|
||||
private const float VERTICAL_SPACING = 4.0f;
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
var att = (HorizontalLine)attribute;
|
||||
|
||||
// Title
|
||||
if (!string.IsNullOrEmpty(att.title))
|
||||
{
|
||||
var style = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontStyle = FontStyle.Bold
|
||||
};
|
||||
|
||||
EditorGUI.LabelField(position, att.title, style);
|
||||
}
|
||||
|
||||
// Line
|
||||
Color oldColor = GUI.color;
|
||||
GUI.color = GUI.skin.label.normal.textColor;
|
||||
var rect = new Rect(position.x, position.yMax - LINE_HEIGHT - VERTICAL_SPACING, position.width, LINE_HEIGHT);
|
||||
GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
|
||||
GUI.color = oldColor;
|
||||
}
|
||||
|
||||
public override float GetHeight()
|
||||
{
|
||||
return base.GetHeight() + VERTICAL_SPACING;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/Decorators/DrawerHorizontalLine.cs.meta
Normal file
11
Editor/Decorators/DrawerHorizontalLine.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4e57076f58a444468405664e6419b6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Editor/Decorators/DrawerMethodHeader.cs
Normal file
32
Editor/Decorators/DrawerMethodHeader.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.Inspector.Editor
|
||||
{
|
||||
[CustomMethodDrawer(typeof(MethodHeader))]
|
||||
public sealed class DrawerMethodHeader : DecoratorMethodDrawer
|
||||
{
|
||||
public override bool Draw(Rect position, DecoratorMethodAttribute attribute)
|
||||
{
|
||||
var att = (MethodHeader)attribute;
|
||||
|
||||
if (string.IsNullOrEmpty(att.title))
|
||||
return false;
|
||||
|
||||
var style = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
fontStyle = FontStyle.Bold,
|
||||
alignment = TextAnchor.LowerLeft
|
||||
};
|
||||
|
||||
EditorGUI.LabelField(position, att.title, style);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetHeight(DecoratorMethodAttribute attribute)
|
||||
{
|
||||
var att = (MethodHeader)attribute;
|
||||
return !string.IsNullOrEmpty(att.title) ? EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing : 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/Decorators/DrawerMethodHeader.cs.meta
Normal file
11
Editor/Decorators/DrawerMethodHeader.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 05076317e0ef8ff409d10caede0335a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue