Files
Cielonos/Assets/OtherPlugins/GraphicsCat/Modules/Common/PropertyAttributes/InspectorDisplayNameDrawer.cs
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

31 lines
987 B
C#

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace GraphicsCat
{
[CustomPropertyDrawer(typeof(InspectorDisplayNameAttribute))]
public class InspectorDisplayNameDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var attr = (InspectorDisplayNameAttribute)attribute;
var content = string.IsNullOrEmpty(attr.tooltip)
? new GUIContent(attr.displayName)
: new GUIContent(attr.displayName, attr.tooltip);
EditorGUI.BeginProperty(position, content, property);
EditorGUI.PropertyField(position, property, content, true); // 'true' allows drawing children
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
}
}
#endif