19 lines
668 B
C#
19 lines
668 B
C#
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
|
|
using UnityEditor;
|
|
using UnityEditor.UIElements;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace RPGCoreCommon.Helpers.Editor.PropertyAttributeDrawers
|
|
{
|
|
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
|
|
public class ReadOnlyDrawer : PropertyDrawer
|
|
{
|
|
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
|
{
|
|
var propertyField = new PropertyField(property);
|
|
propertyField.name = "ReadOnly";
|
|
propertyField.RegisterCallback<GeometryChangedEvent>(_ => propertyField.SetEnabled(false));
|
|
return propertyField;
|
|
}
|
|
}
|
|
} |