// ----------------- // Resources // https://docs.unity3d.com/ScriptReference/MessageType.html // https://discussions.unity.com/t/how-to-make-a-readonly-property-in-inspector/75448/7 // https://docs.unity3d.com/ScriptReference/GUI-enabled.html // ----------------- using UnityEditor; using UnityEngine; [CustomPropertyDrawer(typeof(ReadOnlyAttribute))] public class ReadOnlyDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { GUI.enabled = false; EditorGUI.PropertyField(position, property, label, true); // Include children could be the attribute's property GUI.enabled = true; } }