Last active
October 21, 2015 12:09
-
-
Save romainPechot/d2829c73e8e9ed1cc015 to your computer and use it in GitHub Desktop.
ReadOnlyDrawer for the [ReadOnlyInspector] PropertyAttribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
// put this script inside an Editor folder. | |
[CustomPropertyDrawer(typeof(ReadOnlyInspector))] | |
public class ReadOnlyInspectorDrawer : PropertyDrawer | |
{ | |
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | |
{ | |
GUI.enabled = false; | |
EditorGUI.PropertyField(position, property, label); | |
GUI.enabled = true; | |
}// OnGUI() | |
}// ReadOnlyInspectorDrawer : PropertyDrawer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment