Created
June 2, 2014 20:04
-
-
Save jacobdufault/0f31e898c42f66a0b9f8 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 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); | |
} | |
} | |
} |
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; | |
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