Skip to content

Instantly share code, notes, and snippets.

@jacobdufault
Created June 2, 2014 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobdufault/0f31e898c42f66a0b9f8 to your computer and use it in GitHub Desktop.
Save jacobdufault/0f31e898c42f66a0b9f8 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
namespace FullInspector.Modules.Attributes {
[CustomAttributePropertyEditor(typeof(InspectorDisabledAttribute), ReplaceOthers = true)]
public class InspectorDisabledAttributeEditor<T> : AttributePropertyEditor<T, InspectorDisabledAttribute> {
protected override T Edit(Rect region, GUIContent label, T element, InspectorDisabledAttribute attribute) {
PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null);
EditorGUI.BeginDisabledGroup(true);
element = chain.FirstEditor.Edit(region, label, element);
EditorGUI.EndDisabledGroup();
return element;
}
protected override float GetElementHeight(GUIContent label, T element, InspectorDisabledAttribute attribute) {
PropertyEditorChain chain = PropertyEditor.Get(typeof(T), null);
return chain.FirstEditor.GetElementHeight(label, element);
}
}
}
using System;
using UnityEngine;
namespace FullInspector {
/// <summary>
/// Draws the regular property editor but with a disabled GUI. With the current implementation
/// this is not compatible with other attribute editors.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class InspectorDisabledAttribute : Attribute {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment