A Unity package for managing hierarchical menu navigation with history tracking, input system integration, and automatic UI element selection. Perfect for game menus, settings panels, and any UI that requires structured navigation flow.
Note
This does not replace UGUI's navigation system.
Package Manager > Add/Plus Symbol > Install package via git...
https://github.com/Tirtstan/Sentinal.gitTip
Use the provided Sentinal prefab from the samples for quick setup.
- Add the Core Manager: Place the
SentinalManagersingleton component in your scene. - (Input System) Add helpers: On the same GameObject as
SentinalManager, add:ViewDismissalInputHandler(Cancel/Back + refocus)ActionMapManager(optional, for action map overlays)
- Setup Menu Views: Add
ViewSelectorcomponents to your active toggling menu GameObjects. - (Input System) Per-view input: Add
ViewInputSystemHandleralongsideViewSelectoron views that need input gating and/or action map changes.
Note
Input System features require the Unity Input System package in your project.
Important
The SentinalManager component is required for this package to work. View tracking is triggered by GameObject activation/deactivation (OnEnable/OnDisable).
- Menu/View Tracking: Navigate through multiple menus with automatic history tracking.
- Priority-Based Focus: Views are focused based on priority (higher priority first), with recency as tie-breaker.
- UI Selection: Auto-selection of UI elements with memory of last selected items.
- Dismissal-Protected Views: Views can be tracked but not auto-closed (
preventDismissal). - Exclusive Views: Views that close all other views (except dismissal-protected views) when opened.
- Action Map Overlays: Intelligent action map management that tracks enabled/disabled maps per view.
- Per-View Input Gating: Enable/disable input for specific views based on focus.
- Single or Multi-Player: Support for single PlayerInput or apply to all players simultaneously.
- Efficient Switching: Recomputes action maps when switching between menus, not just on close.
- Configurable Actions: Customisable input actions for canceling and re-selecting.
The central manager that handles all view/menu navigation logic and maintains the view stack.
Public API:
CloseCurrentView()- Close the focused view in the stack.CloseAllViews()- Close all views (optionally excluding dismissal-protected views).TrySelectCurrentView()- Attempt to select the focused view's UI element.AnyViewsOpen- Check if any views are currently open.CurrentView- Get the currently focused view selector (priority + recency).MostRecentView- Get the most recently opened view selector.
Events:
OnAdd- Fired when a new view is added to the stack.OnRemove- Fired when a view is removed from the stack.OnSwitch- Fired when switching between views.
Add this to any GameObject that represents a menu or navigable view. One that will be SetActive(bool).
priority- Focus priority (higher values get focus first; equal priority uses recency).firstSelected- The GameObject to auto-select when this view becomes active.preventDismissal- Track this view, but prevent it from being dismissed byViewDismissalInputHandlerorCloseCurrentView().exclusiveView- Close all other views (except dismissal-protected views) when this view opens.hideOtherViews- Temporarily hide other views while this view is open.trackView- Whether to include this view in the navigation history stack.
preventSelection- Prevent automatic selection (useful for input-only views).autoSelectOnEnable- Automatically select the first element when the view is enabled.rememberLastSelected- Remember and restore the last selected UI element.
- (Input System) Add
ViewInputSystemHandleron the same GameObject to gate input and/or apply action maps.
Listens for two Input System actions:
- Cancel/Back →
SentinalManager.Instance.CloseCurrentView() - Focus →
SentinalManager.Instance.TrySelectCurrentView()
Recommended placement: same GameObject as SentinalManager.
Per-view handler that can:
- Enable/disable “input enabled” state depending on whether the view is the current view (
InputOnlyWhenCurrent). - (Optionally) Apply action map changes when enabled or disabled.
Key fields:
inputOnlyWhenCurrent(default true)viewSelector(optional, but required ifinputOnlyWhenCurrentis true)playerInput/playerIndexapplyToAllPlayersenableActionMaps/disableActionMaps
Singleton that tracks and manages action map overlays across views using ViewInputSystemHandler configuration. Recomputes on view focus changes and restores previous state correctly.
// Your menu GameObject needs:
// 1. ViewSelector component
// 2. Enable/Disable the GameObject to open/close menus
// Open a menu
menuGameObject.SetActive(true); // Automatically tracked by SentinalManager (if ViewSelector is present)
// OR
viewSelector.Open();
// Close current menu
SentinalManager.Instance.CloseCurrentView();
// Close all menus
SentinalManager.Instance.CloseAllViews();[RequireComponent(typeof(ViewSelector))]
public class CustomMenu : MonoBehaviour, ICloseableView
{
[SerializeField] private Animator menuAnimator;
public void Close()
{
// Custom close logic (animations, save data, etc.)
StartCoroutine(CloseWithAnimation());
}
private IEnumerator CloseWithAnimation()
{
menuAnimator.SetTrigger("CloseMenu");
yield return new WaitForSeconds(0.3f);
gameObject.SetActive(false);
}
}private void Start()
{
SentinalManager.OnAdd += OnMenuOpened;
SentinalManager.OnRemove += OnMenuClosed;
SentinalManager.OnSwitch += OnMenuSwitched;
}
private void OnMenuOpened(ViewSelector view)
{
Debug.Log($"Menu opened: {view.name}");
// Update UI, play sounds, etc.
}
private void OnMenuSwitched(ViewSelector from, ViewSelector to)
{
Debug.Log($"Switched from {from?.name} to {to?.name}");
// Handle transition effects
}- Unity 2021.3 or later
- Input System package (optional, for input handling features)
- TextMeshPro (for sample scenes)
The custom editor shows real-time debugging information:
- SentinalManager: Shows focused view vs most recent view, view list with priority and input state.
- ViewSelector: Shows priority, history index, focus state, input enabled, connected PlayerInput.
- ViewInputSystemHandler: Shows input enabled state and action map configuration (Input System).
- Always use GameObject activation (
SetActive(bool)) for menu open/close operations. - Use
ICloseableViewfor menus that need custom close animations or specific menu closure. - Use
preventDismissalfor persistent UI elements like HUDs or a main menu screen. - Use Exclusive Views for modal dialogs or full-screen overlays.
- Set Priority on views that should always be focused when open (e.g., error dialogs).
- Use
ViewInputSystemHandler.InputOnlyWhenCurrentto prevent input conflicts between multiple open views. - Configure Action Maps per view via
ViewInputSystemHandlerto enable both UI and gameplay maps simultaneously when needed (e.g., touch controls).



