DisableAttribute.cs 490 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. #endif
  5. public class DisableAttribute : PropertyAttribute {
  6. }
  7. #if UNITY_EDITOR
  8. [CustomPropertyDrawer(typeof(DisableAttribute))]
  9. public class DisableDrawer : PropertyDrawer
  10. {
  11. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  12. {
  13. EditorGUI.BeginDisabledGroup(true);
  14. EditorGUI.PropertyField(position, property, label);
  15. EditorGUI.EndDisabledGroup();
  16. }
  17. }
  18. #endif