Version 2.1.0.0

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)]
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, 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
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

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.