Skip to content

API reference

Everything is in the UIFlow namespace. Direction below is UnityEngine.UIElements.NavigationMoveEvent.Direction. The XML documentation comments in the source have the full details; your IDE shows them.

Add it next to a UIDocument (Add Component > UI Toolkit > UIFlow Document) to attach a navigator to the document’s root. It re-attaches when the document rebuilds its root.

Member Description
navigator The attached UIFlowNavigator, or null while disabled.
settings The NavigationSettings used by the navigator.
focusOnEnable Focus the entry element as soon as the document is enabled. Default on.
rightStickScrollSpeed Pixels per second the right stick scrolls the ScrollView around the focused element. 0 turns it off. Default 1200.
hideCursorWhileNavigating Hide the mouse cursor while the player uses a gamepad or keyboard. Default off.
debugOverlayKey Key that toggles the debug overlay in the editor and development builds. Default F9; Key.None turns it off.

Adds UIFlow navigation to one subtree of a panel.

Member Description
static Attach(VisualElement root, NavigationSettings settings = null) Attaches a navigator to root and returns it. Returns the existing one if root already has one.
static Get(VisualElement root) The navigator attached to exactly root, or null.
static FindFor(VisualElement element) The navigator whose subtree contains element, or null.
static navigators Every attached navigator.
Detach() Removes the navigator. The subtree goes back to Unity’s default behaviour.
root, settings, isAttached The subtree, its settings, and whether it is still attached.
enabled Set to false to pause the navigator without detaching it.
focusedElement The focused element when it is inside root, else null.
Move(Direction) Moves focus as if the player pressed the direction. Returns true when focus moved.
TryFindTarget(VisualElement from, Direction, out VisualElement target) Where a move would go, without moving.
FindEntryElement() / FocusEntryElement(Direction = None) The element focus lands on when entering from nowhere: the root scope’s remembered or default element, else the top-left one.
FocusInto(VisualElement container) Focuses container’s remembered element, else its default focus, else its top-left element. Use it to open a screen.
RestoreFocus() Puts focus back where the player left it, or the nearest scope still shown, or the entry element.
Evaluate(VisualElement) The first focus rule the element fails, as a RejectionReason (None when it can take focus).
lastStep The NavigationStep that decided the last move.
navigated Event raised after the navigator moved focus: (previous, next, direction). previous is null when focus came from nowhere; direction is None when focus moved without a move event.

None, Entry, Link, Search, Sequence (a tabIndex-ordered scope or Tab in reading order), Scroll, ContainerLink, Wrap, Blocked, HandledByControl (a slider, list view or text field used the direction).

Tuning for one or more navigators. Edit it on the UIFlowDocument inspector, or create one in code.

Property Default Description
coneHalfAngle 60 Half-angle in degrees of the search cone around the pressed direction (5 to 89).
halfPlaneFallback true When nothing is inside the cone, consider every element ahead.
orthogonalWeight 5 Cost of one pixel of sideways gap relative to one pixel of forward gap. Higher prefers aligned elements.
alignmentWeight 0.05 Tie breaker: cost of one pixel of sideways offset between centres.
skipNegativeTabIndex true Skip elements with a negative tabIndex.
skipClippedAndCovered true Skip elements clipped out of view or covered by other elements.
skipTransitioningContainers true Skip elements inside a container running a geometry or opacity transition.
recoverLostFocus true Move focus to the nearest element when the focused one is hidden, disabled or removed.
scrollFocusedIntoView true Scroll the ScrollViews around the new element after each move.
scrollBeforeLeaving true Scroll a page instead of skipping content that is far away or not focusable.
scrollPageFraction 0.75 How much of the viewport one page scroll covers (0.1 to 1).
blockDefaultNavigation true When no target is found, stop Unity’s fallback from moving focus.
tabNavigation Default What Tab does: Default (Unity’s order), Disabled, or ReadingOrder.
restoreFocusOnDeviceSwitch true Restore focus when the player switches from a pointer to a gamepad or keyboard.
Member Description
UIFlowClassNames.excluded (uiflow-excluded) USS class: the element and its subtree are never navigation targets. Pointer input is not affected.
UIFlowClassNames.transitioning (uiflow-transitioning) USS class: nothing inside can take focus while it is set.
element.SetNavigationExcluded(bool) / IsNavigationExcluded() Adds or removes uiflow-excluded.
element.SetNavigationTransitioning(bool) / IsNavigationTransitioning() Adds or removes uiflow-transitioning.
Member Description
SetNavigationLink(Direction, string query) Links a direction to a name, #name, .class, "none" (block) or "auto" / null (search).
SetNavigationLink(Direction, VisualElement target) Links a direction straight to an element.
SetNavigationLinks(up, down, left, right) Sets several queries at once. Null leaves a direction unchanged.
BlockNavigation(Direction) Same as the "none" query.
ClearNavigationLink(Direction) Removes a link set from code or UXML.
GetNavigationLinks() The NavigationLinks set from code or UXML, or null. USS links are not included.

Declared in UXML inside an element’s <Bindings>, with up, down, left and right attributes. Members: GetQuery / SetQuery, GetTarget / SetTarget, isEmpty, and the constants none and auto.

--uiflow-nav-up, --uiflow-nav-down, --uiflow-nav-left, --uiflow-nav-right, each a quoted query. Links from code or UXML win over USS.

A VisualElement that is always a scope. UXML attributes: horizontal-edge, vertical-edge, trap-focus, cancel-behavior, enter-behavior, navigation-order, remember-last-focused, focus-on-show, default-focus. The options property gives its NavigationScopeOptions. USS class: uiflow-scope.

Member Description
MakeNavigationScope() Turns any element into a scope and returns its options. Calling it again returns the same options.
GetNavigationScope() The element’s scope options, or null.
RemoveNavigationScope() Stops the element from being a scope (not for NavigationScope elements).
Member Default Description
element The scope’s container.
horizontalEdge, verticalEdge Escape ScopeEdgeBehavior: Escape, Stop or Wrap.
trapFocus false Moves never take focus out of the scope.
cancelBehavior None ScopeCancelBehavior: None or ReturnToOrigin.
enterBehavior Nearest ScopeEnterBehavior: Nearest or Remembered.
navigationOrder Spatial ScopeNavigationOrder: Spatial or TabIndex.
rememberLastFocused true Remember the last focused element.
focusOnShow false Move focus in whenever the scope is shown.
defaultFocus null Query for the element to focus when nothing is remembered.
lastFocused The remembered element.
origin The element focused before focus entered the scope.
cancelled Event raised on Cancel with ReturnToOrigin, before focus returns. Hide the scope here.
GetEdge(Direction) The edge behaviour for a direction.
ClearMemory() Forgets lastFocused.
Member Description
scrollView.MakeScrollNavigable(bool navigable = true) Makes the ScrollView itself a focus target, so the d-pad scrolls it and leaves it at the ends. For scroll views without focusable content.
Member Description
current The InputDeviceKind used last: None, Pointer, Touch, Keyboard or Gamepad.
isNavigating True for Keyboard and Gamepad.
changed Event raised when current changes.
IsNavigationDevice(InputDeviceKind) True for Keyboard and Gamepad.
Start() / Stop() Starts or stops tracking. Every navigator starts it; call Start to use it without one.
SetCurrent(InputDeviceKind) Overrides the current device, for example in tests.
Constant Class On the panel root while the player uses
navigating uiflow-navigating a gamepad or keyboard
deviceGamepad uiflow-device-gamepad a gamepad
deviceKeyboard uiflow-device-keyboard a keyboard
devicePointer uiflow-device-pointer a mouse or pen
deviceTouch uiflow-device-touch a touch screen
Member Description
FocusRules.Evaluate(element, root, settings) Full rule check of one element, as a RejectionReason.
FocusRules.GetVisibilityRejection(element) Only the visibility rules (display, visibility, opacity, enabled, tabIndex, size).
FocusRules.IsFocusLeaf(element) True for elements that take focus themselves rather than handing it to children.
NavigationScoring.TryScore(from, to, direction, ...) The scoring function, on two panel-space rects.
NavigationScoring.TryScoreWrap(...), IsCardinal, Opposite Helpers for wrapping and directions.

None, DisplayNone, Invisible, Transparent, Disabled, NegativeTabIndex, CannotGrabFocus, ZeroSize, NotInDirection, OutsideCone, Excluded, Transitioning, Clipped, Covered, OutsideScope.

Member Description
UIFlowDebugOverlay.Show(navigator) / Hide / Toggle / IsShown / Get The on-screen overlay.
NavigationDebugger.Analyze(navigator, from, direction, report) Fills a NavigationMoveReport for a move without performing it.
NavigationDebugger.CollectLinks(navigator, results) Every explicit link in the navigator’s subtree, as NavigationLinkInfo.
NavigationDebugger.Describe(candidate) A readable line for a NavigationCandidate.
NavigationMoveRecorder(navigator) Records every move the navigator makes into lastMove, and raises recorded. Dispose it when done.
NavigationMoveReport from, direction, target, step, scope, and candidates (each with element, rect, reason, score, isSource, isTarget).
Window > UI Toolkit > UIFlow Debugger Editor window: navigator picker, overlay toggle, candidate list, and “Why not?” for any element.