Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[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 ToggleGroupAttribute : PropertyGroupAttribute, _Attribute
ToggleGroup is used on any field, and create a toggleable group of options.
Use this to create options that can be enabled or disabled.
The ToggleMemberName functions as the ID for the ToggleGroup, and therefore all members of a toggle group must specify the same toggle member.
This attribute does not support static members!
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;
[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";
}
public ToggleGroupAttribute(string toggleMemberName, float order = 0F, string groupTitle = null)
System.String | toggleMemberName | Name of any bool field or property to enable or disable the ToggleGroup. |
System.Single | order | The order of the group. |
System.String | groupTitle | Use this to name the group differently than toggleMemberName. |
public ToggleGroupAttribute(string toggleMemberName, string groupTitle)
System.String | toggleMemberName | Name of any bool field or property to enable or disable the ToggleGroup. |
System.String | groupTitle | Use this to name the group differently than toggleMemberName. |
public bool CollapseOthersOnExpand
null
ToggleMemberName will be used instead.
public string ToggleGroupTitle
public string ToggleMemberName { get; }
protected override void CombineValuesWith(PropertyGroupAttribute other)
PropertyGroupAttribute | other | Another ToggleGroup. |