ToggleGroupAttribute

ToggleGroup is used on any field, and create a toggleable group of options.

Use this to create options that can be enabled or disabled.

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

Requirements

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

See Also

Constructors

Definition Description
ToggleGroupAttribute(string, int, string) Creates a ToggleGroup. See ToggleGroupAttribute.
ToggleGroupAttribute(string, int, string, string) Obsolete constructor overload.
ToggleGroupAttribute(string, string) Creates a ToggleGroup. See ToggleGroupAttribute.

Properties

Return Type Definition Description
bool CollapseOthersOnExpand If true, all other open toggle groups will collapse once another one opens.
string TitleStringMemberName Name of any string field, property or function, to title the toggle group in the inspector. If null ToggleGroupTitle will be used instead.
string ToggleGroupTitle Title of the toggle group in the inspector. If null ToggleMemberName will be used instead.
string ToggleMemberName Name of any bool field, property or function to enable or disable the ToggleGroup.

Methods

Return Type Definition Description
void CombineValuesWith(PropertyGroupAttribute) Combines the ToggleGroup with another ToggleGroup.

Example

The following example shows how ToggleGroup is used to create two seperate toggleable groups.

public class MyComponent : MonoBehaviour
{
	// This attribute has a title specified for the group. The title only needs to be applied to a single attribute for a group.
	[ToggleGroup("FirstToggle", order: -1, groupTitle: "First")]
	public bool FirstToggle;

	[ToggleGroup("FirstToggle")]
	public int MyInt;

	// This group specifies a member string as the title of the group. A property or a function can also be used.
	[ToggleGroup("SecondToggle", titleStringMemberName: "SecondGroupTitle")]
	public bool SecondToggle { get; set; }

	[ToggleGroup("SecondToggle")]
	public float MyFloat;

	[HideInInspector]
	public string SecondGroupTitle = "Second";
}