Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[DontApplyToListElements]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class OnInspectorGUIAttribute : ShowInInspectorAttribute, _Attribute
OnInspectorGUI is used on any property, and will call the specified function whenever the inspector code is running.
Use this to create custom inspector GUI for an object.
public MyComponent : MonoBehaviour
{
[OnInspectorGUI]
private void MyInspectorGUI()
{
GUILayout.Label("Label drawn from callback");
}
}
The following example shows how a callback can be set before another property.
public MyComponent : MonoBehaviour
{
[OnInspectorGUI("MyInspectorGUI", false)]
public int MyField;
private void MyInspectorGUI()
{
GUILayout.Label("Label before My Field property");
}
}
The following example shows how callbacks can be added both before and after a property.
public MyComponent : MonoBehaviour
{
[OnInspectorGUI("GUIBefore", "GUIAfter")]
public int MyField;
private void GUIBefore()
{
GUILayout.Label("Label before My Field property");
}
private void GUIAfter()
{
GUILayout.Label("Label after My Field property");
}
}
public OnInspectorGUIAttribute()
public OnInspectorGUIAttribute(string action, bool append = true)
System.String | action | The resolved action string that defines the action to be invoked. |
System.Boolean | append | If |
public OnInspectorGUIAttribute(string prepend, string append)
System.String | prepend | The resolved action string that defines the action to be invoked before the property is drawn, if any. |
System.String | append | The resolved action string that defines the action to be invoked after the property is drawn, if any. |
public string Append
public string Prepend