title | description | author | ms.author | ms.date | keywords |
---|---|---|---|---|---|
Toggle Collection |
Description of toggle collections in MRTK3 |
Zee2 |
finnsinclair |
9/19/2022 |
Unity, HoloLens, HoloLens 2, Mixed Reality, development, MRTK, MRTK3, Button, PressableButton, Toggle, ToggleCollection, radio button, toggle |
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.