Skip to content

Instantly share code, notes, and snippets.

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/09bbb65a676f012ca3ee to your computer and use it in GitHub Desktop.
Save jacobdufault/09bbb65a676f012ca3ee to your computer and use it in GitHub Desktop.
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