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¶
- Ensure the base menu scope is current and its opener is selected.
- Activate the modal GameObject.
- Call
PushModalwith 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¶
- Deactivate or otherwise close the modal UI.
- Call
PopModal.
If the saved base selection remains valid, it is restored exactly. Otherwise, the manager resolves the base scope's normal focus target.
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.