Version 3.3.1.2

Odin has a dedicated attribute overview with examples

InfoBoxAttribute 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 = true, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class InfoBoxAttribute : Attribute, _Attribute

InfoBox is used on any property, and display a text box above the property in the inspector.

Use this to add comments or warn about the use of different properties.

Inheritance
  • System.Object
  • System.Attribute
  • InfoBoxAttribute
Example

The following example shows different info box types.

public class MyComponent : MonoBehaviour
{
	[InfoBox("This is an int property")]
	public int MyInt;

	[InfoBox("This info box is a warning", InfoMessageType.Warning)]
	public float MyFloat;

	[InfoBox("This info box is an error", InfoMessageType.Error)]
	public object MyObject;

	[InfoBox("This info box is just a box", InfoMessageType.None)]
	public Vector3 MyVector;
}
Example

The following example how info boxes can be hidden by fields and properties.

public class MyComponent : MonoBehaviour
{
	[InfoBox("This info box is hidden by an instance field.", "InstanceShowInfoBoxField")]
	public int MyInt;
	public bool InstanceShowInfoBoxField;

	[InfoBox("This info box is hideable by a static field.", "StaticShowInfoBoxField")]
	public float MyFloat;
	public static bool StaticShowInfoBoxField;

	[InfoBox("This info box is hidden by an instance property.", "InstanceShowInfoBoxProperty")]
	public int MyOtherInt;
	public bool InstanceShowInfoBoxProperty { get; set; }

	[InfoBox("This info box is hideable by a static property.", "StaticShowInfoBoxProperty")]
	public float MyOtherFloat;
	public static bool StaticShowInfoBoxProperty { get; set; }
}
Example

The following example shows how info boxes can be hidden by functions.

public class MyComponent : MonoBehaviour
{
	[InfoBox("This info box is hidden by an instance function.", "InstanceShowFunction")]
	public int MyInt;
	public bool InstanceShowFunction()
	{
		return this.MyInt == 0;
	}

	[InfoBox("This info box is hidden by a static function.", "StaticShowFunction")]
	public short MyShort;
	public bool StaticShowFunction()
	{
		return true;
	}

	// You can also specify a function with the same type of parameter.
	// Use this to specify the same function, for multiple different properties.
	[InfoBox("This info box is hidden by an instance function with a parameter.", "InstanceShowParameterFunction")]
	public GameObject MyGameObject;
	public bool InstanceShowParameterFunction(GameObject property)
	{
		return property != null;
	}

	[InfoBox("This info box is hidden by a static function with a parameter.", "StaticShowParameterFunction")]
	public Vector3 MyVector;
	public bool StaticShowParameterFunction(Vector3 property)
	{
		return property.magnitude == 0f;
	}
}

Constructors

InfoBoxAttribute(String, InfoMessageType, String)
Displays an info box above the property.
public InfoBoxAttribute(string message, InfoMessageType infoMessageType = InfoMessageType.Info, string visibleIfMemberName = null)
Parameters
System.String message

The message for the message box. Supports referencing a member string field, property or method by using $.

InfoMessageType infoMessageType

The type of the message box.

System.String visibleIfMemberName

Name of member bool to show or hide the message box.

InfoBoxAttribute(String, SdfIconType, String)
Displays an info box above the property.
public InfoBoxAttribute(string message, SdfIconType icon, string visibleIfMemberName = null)
Parameters
System.String message

The message for the message box. Supports referencing a member string field, property or method by using $.

SdfIconType icon

The icon to be displayed next to the message.

System.String visibleIfMemberName

Name of member bool to show or hide the message box.

InfoBoxAttribute(String, String)
Displays an info box above the property.
public InfoBoxAttribute(string message, string visibleIfMemberName)
Parameters
System.String message

The message for the message box. Supports referencing a member string field, property or method by using $.

System.String visibleIfMemberName

Name of member bool to show or hide the message box.

Fields

GUIAlwaysEnabled
When true the InfoBox will ignore the GUI.enable flag and always draw as enabled.
public bool GUIAlwaysEnabled
IconColor
Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string IconColor
InfoMessageType
The type of the message box.
public InfoMessageType InfoMessageType
Message
The message to display in the info box.
public string Message
VisibleIf
Optional member field, property or function to show and hide the info box.
public string VisibleIf

Properties

HasDefinedIcon
public bool HasDefinedIcon { get; }
Icon
The icon to be displayed next to the message.
public SdfIconType Icon { get; set; }