Navigation Group Switch Controller
A Navigation Group Switch Controller is used to navigate between several Navigation Groups.
Without that, only the Selectables of the currently focused Navigation Group can be navigated and there would be no clean way to navigate to another Navigation Group without coding.
Inspector Properties
enabled / gameObject.activeInHierarchy
It is important to know that this component is bound to its enabled-state. If it becomes disabled (or the game object becomes inactive) and "Unfocus Navigation Group On Disable" is checked (see below), it will check if the current Navigation Group is focused, and will unfocus it. It also deselects the current selection in that case (Better Navigation will try to find something else to focus - preferably of a Navigation Group that would become focus because of all that).
If it becomes enabled (or the game object is activated), it tries to focus the initial Navigation Group (which will then try to select the initial Selectable). If this fails, it will try again the next three frames (in case the navigation groups are created delayed), before it gives up (in that case, the previous group / selection remains).
Initialize One Frame Delayed
Does the initialization logic (collecting & selecting the initial Navigation Group) after one frame instead of immediately.
You may want to check this if you know that your Navigation groups are created on the fly after the Navigation Group Switch Controller is instantiated.
Is Controlling Navigation Groups
This must always be checked for a Navigation Group Switch Controller as this is the purpose of this component.
(You may wonder why this is shown in the inspector at all: The base class is "Navigation Controller" which only makes use of the indented properties below, if this is checked. To have a visual connection to the Tab Switch Controller, which also derives from "Navigation Controller", this is displayed here)
Trigger Current Toggle On Switch
If this is checked and the currently active selectable would be a (Better) Toggle when the user decides to switch the Navigation Group, that Toggle's "isOn" state would be set to true.
This might be useful, if you have something like a file system: On the left you have a Navigation Group with the folders, next to it you have another Navigation Group with the files for any folder. When the user presses "right" on one of the root folders, the content for the files would be generated because the folder-toggle would be "checked" and the files would be navigated as the user navigated to the right Navigation Group.
Navigation Groups
The Navigation Group Collection that holds all Navigation Groups, this Navigation Group Switch Controller is managing.
Navigation Group Switch Behavior
Switch Group By Moving
If checked, the user can use the default navigation method to switch between groups (for gamepad: Usually the left stick). If not checked, the group can only be switched by using the "Navigation Group Switch Bindings" (see below).
Smart Select for Move out of group
Shall "Smart Select" (see below) be used if the user navigates between groups with the default navigation method (see above)?
Smart Select for switch by Button
Shall "Smart Select" (see below) be used if the user navigates between groups using the "Navigation Group Switch Bindings" (see below)?
Smart Select
Smart select means that the Navigation Group that becomes focused should not use their usual method to select the initial element. Instead, it should select the element that is closest to the element that was selected in the previous Navigation Group.
Enable / Disable Behavior
Unfocus Navigation Group on Disable
If this Navigation Group Switch Controller is disabled, it also disables the current Navigation Group if it is managed by it, as long as this property is checked (see above "enabled"). Otherwise, the navigation group remains focused.
Disable When No Managed Group Active
If this is checked, the enable-state will automatically be set to false, when a Navigation Group becomes focused that is not managed by this Navigation Group Switch Controller.
Enable When Managed Group Active
If this is checked, the enable-state will automatically be set to true, when a Navigation Group becomes focused that is managed by this Navigation Group Switch Controller.
Navigation Group Switch Bindings
There are Input Action Bindings for:
- Navigate Up
- Navigate Down
- Navigate Left
- Navigate Right
If the corresponding input action is detected and the Navigation Group Switch Controller is active and one of its groups is focused, it switches to a group at the corresponding direction. Similar to how selectables are navigated. That group becomes focused and selects a Selectable.
For every of those bindings an Input Action Visualization can be defined.
Code Access
Static
ActiveControllers
A collection of all currently active NavigationControllers (which is a base class of this component).
Entries can be modified while looping over them.
Not thread safe.
AllControllers
A collection of all NavigationControllers that are in the present (including inactive and disabled ones)
Entries can be modified while looping over them.
Not thread safe.
ActiveHandlers
A collection of all currently active ButtonInteractionHandlers (which is a base class of this component).
Entries can be modified while looping over them.
Not thread safe.
TryFocusAnotherGroup()
Trys to focus a Navigation Group which is currently no focused and managed by any active Navigation Group Switch Controller.
If you don't pass "requiresSelectableInGroup: false", it excludes Navigation Groups that have no Selectables in them.
Returns true, if it could focus another group fulfilling all criteria, otherwise false.
Non-Static
IsInitialized
Returns true as soon as the controller is fully initialized.
IsControllingNavigationGroups
Always returns true. See Inspector Properties.
ControlledNavigationGroups
see above (Inspector Properties: Navigation Groups).
SwitchGroupByMoving
Gets or sets that value. See Inspector Properties.
UnfocusNavigationOnDisable
Gets or sets the value. See Inspector Properties.
NavigateLeftInput / NavigateRightInput / NavigateUpInput / NavigateDownInput
Gets the corresponding input binding.
NavigateLeftVisualization / NavigateRightVisualization / NavigateUpVisualization / NavigateDownVisualization
Gets the corresponding Input Action Visualization.