summaryrefslogtreecommitdiff
path: root/Assets/Mountools/Tools/Editor/LabelAttributeDrawer.cs
blob: 7a1133459d2c82b4d9b1e8a4e329e1b5692b8fd5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

namespace Mountools.Tools.Editor
{
    [CustomPropertyDrawer(typeof(LabelAttribute))]
    public class LabelAttributeDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (attribute is LabelAttribute attr && attr.Name.Length > 0)
            {
                label.text = attr.Name;
            }
            EditorGUI.PropertyField(position, property, label);
        }
    }
}
#endif