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.
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;
}
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; }
}
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;
}
}
public InfoBoxAttribute(string message, InfoMessageType infoMessageType = InfoMessageType.Info, string visibleIfMemberName = null)
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. |
public InfoBoxAttribute(string message, SdfIconType icon, string visibleIfMemberName = null)
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. |
public InfoBoxAttribute(string message, string visibleIfMemberName)
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. |
true
the InfoBox will ignore the GUI.enable flag and always draw as enabled.
public bool GUIAlwaysEnabled
public string IconColor
public InfoMessageType InfoMessageType
public string Message
public string VisibleIf
public bool HasDefinedIcon { get; }
public SdfIconType Icon { get; set; }