Files
2026-04-25 23:37:10 +02:00

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;
}
}
}