Toggle Collection — MRTK3
ToggleCollection provides a simple mechanism for grouping multiple StatefulInteractables together and enforcing an exclusive toggle state. This behavior follows the radio button pattern, and is implemented similarly to Unity UI's ToggleGroup.
Similar to the Unity UI ToggleGroup, ToggleCollection
automatically groups and manages all StatefulInteractable
children. On the other hand, if you'd like to manually specify which Interactables are managed by the group, the Toggles
list can be manually populated in the Inspector. When left blank, ToggleCollection
will automatically populate the list.
When a managed StatefulInteractable
is toggled, all other Interactables in the Toggles
list are detoggled with ForceSetToggled
. Toggle events will fire on each Interactable.
Allow Switch Off corresponds to the Selection Mode on each Interactable; when the option is checked, each Interactable is set to Toggle
. When unchecked, each Interactable is configured to One-way Toggle
.
Subscribe to the OnToggleSelected
event to receive callbacks with the index of the choice as the parameter.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for