Skip to content

Layout constraints

The Layout Constraint (SmartNavigationLayoutConstraint) component describes the directional topology of descendant controls within a Navigation Group (SmartNavigationGroup). Set Topology in the Inspector or use the public Topology property.

The nearest active constraint between a Selectable and its navigation group applies to that control.

Freeform

Freeform allows all directions and uses the group's bounds-aware spatial scoring. Use it for irregular or mixed layouts that do not have strict row/column structure.

VerticalList

VerticalList allows Up and Down from constrained descendants. Left and Right resolve to no target, including at the list boundary. This prevents a single-column list from escaping horizontally into nearby controls.

HorizontalList

HorizontalList allows Left and Right from constrained descendants. Up and Down resolve to no target.

Grid

Grid derives directional neighbors from visual row and column lanes and overlapping screen-space bounds. Horizontal navigation stays within the source row, and vertical navigation stays within the source column.

At a grid boundary, the group can still consider a sensible external control outside the constraint when it shares the relevant visual lane.

Ragged grid example

1  2  3
4  5  6
7  8

From Item 8, Right has no internal target because no third item exists in that row. It does not jump diagonally to Item 6 in the previous row. Likewise, Item 6 has no internal Down target because the third column does not continue into the final row.

This behavior defines the Smart Grid topology; it is not a claim that every Unity Automatic grid produces an incorrect result.

Changing topology at runtime

Assigning Topology marks the owning group dirty. With automatic rebuilding enabled, the new topology is applied before a later canvas render. Otherwise, update the layout first and call RebuildNavigation() yourself.

layoutConstraint.Topology = SmartNavigationTopology.Grid;
navigationGroup.MarkNavigationDirty();