ToggleAttribute

Toggle is used on any field or property, and allows to enable or disable the property in the inspector.

Use this to create a property that can be turned off or on.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)384, AllowMultiple = False, Inherited = True)]
public sealed class ToggleAttribute : Attribute
}

Requirements

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

See Also

Constructors

Definition Description
ToggleAttribute(string) Create a toggleable property in the inspector.

Properties

Return Type Definition Description
bool CollapseOthersOnExpand If true, all other open toggle groups will collapse once another one opens.
string ToggleMemberName Name of any bool field or property to enable or disable the object.

Example

The following example shows how Toggle is used to create a toggleable property.

public class MyComponent : MonoBehaviour
{
	[Toggle("Enabled")]
	public MyToggleable MyToggler = new MyToggleable();
}

public class MyToggleable
{
	public bool Enabled;

	public int MyValue;
}