Skip to content

Instantly share code, notes, and snippets.

@cubed2d
Created July 25, 2016 05:39
Show Gist options
  • Save cubed2d/33ecf44312fbf12fff6a24a1ccae31b5 to your computer and use it in GitHub Desktop.
Save cubed2d/33ecf44312fbf12fff6a24a1ccae31b5 to your computer and use it in GitHub Desktop.
Read Only property drawer extension for unity
// NOTE put in a Editor folder
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label);
GUI.enabled = true;
}
}
// NOTE DONT put in an editor folder
using UnityEngine;
public class ReadOnlyAttribute : PropertyAttribute { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment