Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using UnityEngine;
namespace FullInspector.Modules.Attributes {
[CustomAttributePropertyEditor(typeof(InspectorSkipInheritanceAttribute), ReplaceOthers = true)]
public class InspectorSkipInheritanceAttributeEditor<T> : AttributePropertyEditor<T, InspectorSkipInheritanceAttribute> {
private static IPropertyEditor GetEditor(object element) {
if (element == null) {
return PropertyEditor.Get(typeof(T), null).FirstEditor;
}
return PropertyEditor.Get(element.GetType(), null).FirstEditor;
}
protected override T Edit(Rect region, GUIContent label, T element, InspectorSkipInheritanceAttribute attribute) {
return GetEditor(element).Edit(region, label, element);
}
protected override float GetElementHeight(GUIContent label, T element, InspectorSkipInheritanceAttribute attribute) {
return GetEditor(element).GetElementHeight(label, element);
}
public override GUIContent GetFoldoutHeader(GUIContent label, object element) {
return GetEditor(element).GetFoldoutHeader(label, element);
}
protected override T OnSceneGUI(T element, InspectorSkipInheritanceAttribute attribute) {
return GetEditor(element).OnSceneGUI(element);
}
}
}
using System;
namespace FullInspector {
/// <summary>
/// Adding [InspectorSkipInheritance] will prevent the drop-down type selection editor from
/// being shown.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class InspectorSkipInheritanceAttribute : Attribute, IInspectorAttributeOrder {
double IInspectorAttributeOrder.Order {
get {
return double.MinValue;
}
}
}
}
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.