Skip to content

Modals

SmartFocusManager uses a focus stack for modal and popup flows. The application remains responsible for opening, closing, and identifying modal panels.

Open a modal

  1. Ensure the base menu scope is current and its opener is selected.
  2. Activate the modal GameObject.
  3. Call PushModal with the active modal scope.

The manager records the current base scope and its exact valid selection, then focuses the modal scope using its remembered/default/fallback order.

Close a modal

  1. Deactivate or otherwise close the modal UI.
  2. Call PopModal.

If the saved base selection remains valid, it is restored exactly. Otherwise, the manager resolves the base scope's normal focus target.

The modal receives focus while open, then the exact valid opener is restored when it closes.
using LevelArgento.SmartUINavigation;
using UnityEngine;

public sealed class PopupController : MonoBehaviour
{
    [SerializeField] private SmartFocusManager focusManager;
    [SerializeField] private GameObject popup;
    [SerializeField] private SmartFocusScope popupScope;

    public void Open()
    {
        popup.SetActive(true);
        focusManager.PushModal(popupScope);
    }

    public void Close()
    {
        popup.SetActive(false);
        focusManager.PopModal();
    }
}

The modal scope passed to PushModal must exist and be active and enabled; otherwise, the method returns false. PopModal returns false when no restoration entry exists.

Calling SetScope, including SetScope(null), clears the modal restoration stack. Do not use SetScope to enter a popup when opener restoration is required.

The manager does not discover third-party or application-specific modal systems automatically. Integrate their open/close events with PushModal and PopModal, and make sure asynchronous close logic calls PopModal at the intended time.