Created
June 3, 2014 15:01
-
-
Save jacobdufault/09bbb65a676f012ca3ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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