ReadOnlyDrawer.cs 650 B

12345678910111213141516171819202122
  1. using UnityEditor;
  2. namespace UnityEngine
  3. {
  4. /// <summary>
  5. /// ÉèÖÃÊôÐÔÖ»¶Á
  6. /// </summary>
  7. [CustomPropertyDrawer(typeof(DisplayOnly))]
  8. public class ReadOnlyDrawer : PropertyDrawer
  9. {
  10. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  11. {
  12. return EditorGUI.GetPropertyHeight(property, label, true);
  13. }
  14. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  15. {
  16. GUI.enabled = false;
  17. EditorGUI.PropertyField(position, property, label, true);
  18. GUI.enabled = true;
  19. }
  20. }
  21. }