Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.