Version 3.3.0.2

Odin has a dedicated attribute overview with examples

OnInspectorGUIAttribute class

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.

Inheritance
Example

public MyComponent : MonoBehaviour
{
	[OnInspectorGUI]
	private void MyInspectorGUI()
	{
		GUILayout.Label("Label drawn from callback");
	}
}
Example

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");
	}
}
Example

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");
	}
}

Constructors

OnInspectorGUIAttribute()
Calls a function decorated with this attribute, when the inspector is being drawn.
public OnInspectorGUIAttribute()
OnInspectorGUIAttribute(String, Boolean)
Adds callbacks to the specified action when the property is being drawn.
public OnInspectorGUIAttribute(string action, bool append = true)
Parameters
System.String action

The resolved action string that defines the action to be invoked.

System.Boolean append

If true the method will be called after the property has been drawn. Otherwise the method will be called before.

OnInspectorGUIAttribute(String, String)
Adds callbacks to the specified actions when the property is being drawn.
public OnInspectorGUIAttribute(string prepend, string append)
Parameters
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.

Fields

Append
The resolved action string that defines the action to be invoked after the property is drawn, if any.
public string Append
Prepend
The resolved action string that defines the action to be invoked before the property is drawn, if any.
public string Prepend