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


Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector

See Also


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.


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.


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


The following example shows how ToggleGroup is used to create two separate 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;

	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; }

	public float MyFloat;

	public string SecondGroupTitle = "Second";