InfoBoxAttribute

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.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)448, AllowMultiple = True, Inherited = True)]
[DontApplyToListElementsAttribute]
public sealed class InfoBoxAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.5.0

See Also

Constructors

Definition Description
InfoBoxAttribute(string, InfoMessageType, string) Displays an info box above the property.
InfoBoxAttribute(string, string) Displays an info box above the property.

Properties

Return Type Definition Description
InfoMessageType InfoMessageType The type of the message box.
string Message The message to display in the info box.
string VisibleIf Optional member field, property or function to show and hide the info box.

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", InfoBoxType.Warning)]
	public float MyFloat;

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

	[InfoBox("This info box is just a box", InfoBoxType.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;
	}
}