mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
27 lines
937 B
C#
27 lines
937 B
C#
using TriInspector;
|
|
using TriInspector.Drawers;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
[assembly: RegisterTriAttributeDrawer(typeof(DisplayAsStringDrawer), TriDrawerOrder.Decorator, ApplyOnArrayElement = true)]
|
|
|
|
namespace TriInspector.Drawers
|
|
{
|
|
public class DisplayAsStringDrawer : TriAttributeDrawer<DisplayAsStringAttribute>
|
|
{
|
|
public override float GetHeight(float width, TriProperty property, TriElement next)
|
|
{
|
|
return EditorGUIUtility.singleLineHeight;
|
|
}
|
|
|
|
public override void OnGUI(Rect position, TriProperty property, TriElement next)
|
|
{
|
|
var value = property.Value;
|
|
var text = value != null ? value.ToString() : "Null";
|
|
|
|
var controlId = GUIUtility.GetControlID(FocusType.Passive);
|
|
position = EditorGUI.PrefixLabel(position, controlId, property.DisplayNameContent);
|
|
GUI.Label(position, text);
|
|
}
|
|
}
|
|
} |