Cross Input Support
Scripting with the CrossInputSupport class.
The CrossInputSupport
class provides keyboard and controller navigation support for Inventool's UI when set up properly with the PlayerInput
and UIDocument
components.
Fields & Properties
document
The UI document solely for the element selector.
UIDocument
public
input
The player input component.
PlayerInput
public
playerMap
The player input map name.
string
public
menuMap
The menu input map name.
string
public
selector
The targetter visual element.
VisualElement
public
top
The document currently over all others.
CrossInputSupportedWindow
public
focusables
A list of focusable visual elements of the top document.
List<VisualElement>
public
selectedFocusable
The currently targetted focusable.
VisualElement
public
initialFocusable
The initial focusable element.
VisualElement
public
windows
A list of all registered UI documents in the scene.
List<CrossInputSupportedWindow>
public
initialFocusablePosition
The placement of the initial focusable.
InitialFocusablePosition
public
scrollingSensitivity
The scrolling sensitivity used when locked on a scroller.
float
public
animationCoroutine
The coroutine that handles the selector's animation.
Coroutine
private
moveHeldCoroutine
A coroutine that handles move button holding.
Coroutine
private
lockedMoveAction
An action to execute when the selector is locked on a focusable.
Action
private
moveDirection
The current move direction.
Vector2
private
isLocked
If the selector is currently locked on the selected focusable.
bool
private
Active Instance
You can get the active CrossInputSupport
instance with CrossInputSupport.Instance
. Ensure there's an instance of it in your scene before using this field.
Registration
The CrossInputSupport
method only works on registeredCrossInputSupportedWindow
components. Use the Register
method to register a CrossInputSupportedWindow
.
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.
Focusables
Focusables are VisualElement
's that can be focused by the CrossInputSupport
seelctor.
Find Focusables
To find all focusables of the top document, use the FindFocusables
method. This will update the focusables
field.
Find Initial
The initial focusable is the first one selected when navigating as decided by the initialFocusablePosition
field. Use the FindInitial to get the initial focusable. this will update the initialFocusable
field.
Selection
A focusable VisualElement is selected when navigating with any move button. The selected focusable 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 focusable, use SelectInitial
.
Deselect
Use Deselect
to deselect the current selection and hide the selector graphic.
Alternatively, you can use AssessSelection
, which will deselect the current selection if it's not enabled or focusable anymore.
Locking
To lock on a focusable, when a focusable is selected, use the Lock
method. When a focusable is locked on, navigation will be prevented.
Unlocking
The Unlock
method will stop locking on to a focusable.
Moving
Use the Move method to move the selector towards a direction.
Last updated