Skip to content

Smart navigation

The Navigation Group (SmartNavigationGroup) component generates Up, Down, Left, and Right targets for uGUI Selectable controls beneath it. It uses current screen-space RectTransform bounds to prefer candidates in the requested direction with sensible alignment and proximity.

The result is deterministic for the same hierarchy and layout. It is intended for irregular menus and structured layouts where explicit, reproducible links are preferable to Unity's runtime Automatic mode. Ordinary menus may work equally well with Unity's built-in navigation.

The sample's irregular layout keeps directional movement deliberate across staggered controls.

Participants

A participant must:

  • be a descendant of the group;
  • use a RectTransform;
  • be active and enabled;
  • be interactable; and
  • not belong to a nested Navigation Group.

Invalid controls are excluded as navigation targets. Transition settings, colors, animation triggers, and target graphics are not changed.

RebuildNavigation() calculates all four directions, applies any active manual overrides, and writes the result to each participant's Selectable.navigation property using Navigation.Mode.Explicit.

This replaces the participant's previous navigation mode and directional targets. It does not permanently modify unrelated controls outside the group. A control removed from the group can retain navigation that was previously written directly onto that control; reset or rebuild it elsewhere if that matters to the application.

Rebuilding

Rebuild Automatically is enabled by default. The group marks itself dirty for relevant hierarchy, layout, validity, and transform changes, then rebuilds before a later canvas render.

Use the public methods when coordinating custom UI code:

navigationGroup.MarkNavigationDirty();

MarkNavigationDirty() schedules an automatic rebuild only while RebuildAutomatically is enabled. If automatic rebuilding is disabled, call:

navigationGroup.RebuildNavigation();

The component also exposes Rebuild Navigation in its context menu.

For runtime-generated layouts, allow Unity's layout system to update positions before rebuilding. See dynamic UI.

Structured content

Add the Layout Constraint (SmartNavigationLayoutConstraint) component around list or grid content when its topology should control valid directions. Freeform controls continue to use spatial candidate scoring. See layout constraints.