Dynamic UI¶
The Navigation Group (SmartNavigationGroup) component supports common runtime changes without rebuilding continuously when nothing has changed.
With Rebuild Automatically enabled, it detects or receives dirty signals for:
- added and removed
Selectablecontrols; - hierarchy and sibling-order changes;
- active/inactive changes;
- enabled/disabled changes;
- interactable changes;
RectTransformsize, transform, and layout changes; and- layout-constraint or override changes.
The group checks relevant observed state before canvas rendering and rebuilds only when dirty or changed. This monitoring has a runtime cost; it is not described as zero-cost.
Preferred deferred rebuild¶
For a VerticalLayoutGroup, HorizontalLayoutGroup, or GridLayoutGroup, mark both the layout and navigation dirty after changing content:
using LevelArgento.SmartUINavigation;
using UnityEngine;
using UnityEngine.UI;
public sealed class DynamicMenu : MonoBehaviour
{
[SerializeField] private RectTransform content;
[SerializeField] private SmartNavigationGroup navigationGroup;
public void ContentChanged()
{
LayoutRebuilder.MarkLayoutForRebuild(content);
navigationGroup.MarkNavigationDirty();
}
}
With automatic rebuilding enabled, Unity updates the layout and the group rebuilds before a later canvas render.
Immediate rebuild¶
When links are required synchronously in the same call, force the relevant layout first:
Use this only when immediate results are required. For custom asynchronous transitions or layout animation, call the rebuild after final RectTransform positions are available.
Automatic rebuilding disabled¶
MarkNavigationDirty() records the dirty state but does not rebuild while RebuildAutomatically is false. Call RebuildNavigation() explicitly after layout settles.
Removed controls¶
Rebuilding stops removed or invalid controls from being targets of current participants. A removed control may retain the explicit navigation previously written to its own Selectable, because it is no longer part of the group being rebuilt. Clear or replace that control's navigation if it will be reused elsewhere.
If the selected control becomes invalid during a content change, the Focus Manager (SmartFocusManager) component can recover selection within the active focus scope according to its configured input-mode policy.