Skip to content

Instantly share code, notes, and snippets.

@romainPechot
Last active October 21, 2015 12:09
Show Gist options
  • Save romainPechot/d2829c73e8e9ed1cc015 to your computer and use it in GitHub Desktop.
Save romainPechot/d2829c73e8e9ed1cc015 to your computer and use it in GitHub Desktop.
ReadOnlyDrawer for the [ReadOnlyInspector] PropertyAttribute
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