-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathNoLabelDrawer.cs
39 lines (35 loc) · 991 Bytes
/
NoLabelDrawer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#if UNITY_EDITOR
using cratesmith.assetui;
using UnityEditor;
#endif
using UnityEngine;
namespace Cratesmith.AssetUI
{
public interface INoLabelDrawer
{
}
public class NoLabelPropertyAttribute : PropertyAttribute
{
}
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(INoLabelDrawer), true)]
[CustomPropertyDrawer(typeof(NoLabelPropertyAttribute), true)]
public class NoLabelDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, GUIContent.none, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
ObjectDrawer.ObjectField(position, property, fieldInfo.FieldType.GetElementType() ?? fieldInfo.FieldType, GUIContent.none);
} else
{
EditorGUI.PropertyField(position, property, GUIContent.none, true);
}
}
}
#endif
}