Cross Input Support UGUI
Scripting with the CrossInputSupportUGUI class.
The CrossInputSupportUGUI
class provides keyboard and controller navigation support for Inventool's UI when set up properly with the PlayerInput
, SelectorUGUI
and TargetSelectable
components.
Fields & Properties
selector
The selector.
SelectorUGUI
public
input
The player input component.
PlayerInput
public
playerMap
The player input map name.
string
public
menuMap
The menu input map name.
string
public
top
The window currently over all others.
CrossInputSupportedWindowUGUI
public
selectables
A list of selectables of the top window.
List<TargetSelectable>
public
selection
The currently targeted selectable.
TargetSelectable
public
initialSelectable
The initial selectable.
TargetSelectable
public
windows
A list of all registered windows in the scene.
List<CrossInputSupportedWindowUGUI>
public
initialSelectablePosition
The placement of the initial selectable.
InitialSelectablePosition
public
scrollingSensitivity
The scrolling sensitivity used when locked on a scroller.
float
public
moveHeldCoroutine
A coroutine that handles move button holding.
Coroutine
private
lockedMoveAction
An action to execute when the selector is locked on a selectable.
Action
private
moveDirection
The current move direction.
Vector2
private
isLocked
If the selector is currently locked on the selected selectable.
bool
private
Active Instance
You can get the active CrossInputSupportUGUI
instance with CrossInputSupportUGUI.Instance
. Ensure there's an instance of it in your scene before using this field.
Registration
The CrossInputSupportUGUI
class only works on registeredCrossInputSupportedWindowUGUI
components. Use the Register
method to register a CrossInputSupportedWindowUGUI
.
Use Unregister
to have the opposite effect.
Top Window
The window at the top of every other one will have navigation control. To update the top window, use the DetermineTop
method.
Selectables
Selectables are UI objects that can be selected by the CrossInputSupportUGUI
component.
Find Selectables
To find all selectables of the top document, use the FindSelectables
method. This will update the selectables
field.
Find Initial
The initial selectable is the first one selected when navigating as decided by the initialSelectablePosition
field. Use the FindInitial
method to get the initial selectable. this will update the initialSelectable
field.
Selection
A Selectable is hovered when navigating with any move button. The hovered selectable will have the selector targeting it.
Select
To simulate a selection, use the Select
method. If the selector is locked, this method will do nothing.
To select the initial selectable, use SelectInitial
.
Deselect
Use Deselect
to stop hovering and hide the selector graphic.
Alternatively, you can use AssessSelection
, which will deselect the current selection if it's not enabled or selectable anymore.
Locking
To lock on a selectable, when one is hovered, use the Lock
method. When a selectable is locked on, navigation will be prevented.
Unlocking
The Unlock
method will stop locking on to a selectable.
Moving
Use the Move method to move the selector towards a direction.
Last updated