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.
- Root Views: Views that don't get auto-closed and have special permissions around being closed; can still be hidden (
rootView). - Exclusive Views: Views that close all other views (except root 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.
- Default Action Maps: Configure action maps to apply when no non-root views are open (e.g., gameplay maps when only HUD/main menu is visible).
- Flexible Action Map Configuration: Use
ActionMapConfigto specify both action map names and their enabled/disabled state for when views are enabled or disabled. - Dual Event System Support: Supports both C# Events (
InvokeCSharpEvents) and Unity Events (InvokeUnityEvents) notification behaviors onPlayerInput.
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 root 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.rootView- Root view: does not get auto-closed, has special permissions around being closed; can still be hidden (e.g. main menu, HUD).exclusiveView- Close all other views (except root 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/playerIndexapplyToAllPlayersonEnabledActionMaps- Action maps to configure when this handler is enabled (view is active). Each entry specifies the action map name and whether to enable or disable it.onDisabledActionMaps- Action maps to configure when this handler is disabled (view is inactive). Each entry specifies the action map name and whether to enable or disable it.
Singleton that tracks and manages action map overlays across views using ViewInputSystemHandler configuration. Recomputes on view focus changes and restores previous state correctly.
Key features:
- Default Action Maps: Configure action maps to apply when no non-root views are open (controlled by
useDefaultActionMapstoggle). - Action Map History: Tracks the latest action map state per view selector (source); the same selector overwrites its previous entry. Editor shows one row per view with player index, action type (Enable/Disable/Restore), and map names.
- Automatic Restoration: Restores action maps to their previous state when views are closed or disabled.
Configuration:
useDefaultActionMaps- If true, appliesdefaultActionMapswhen no non-root views are open. If false, uses current in-memory state.defaultActionMaps- Array ofActionMapConfigentries specifying which action maps to enable/disable when only root views are open.
// 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)
Sentinal supports both C# Events (InvokeCSharpEvents) and Unity Events (InvokeUnityEvents) notification behaviors on PlayerInput components.
Recommended: Set PlayerInput.notificationBehavior to either:
InvokeCSharpEvents- Uses C# events (onActionTriggered,onControlsChanged, etc.)InvokeUnityEvents- Uses Unity Events (actionEvents,controlsChangedEvent, etc.)
Note: If PlayerInput.notificationBehavior is set to SendMessages or BroadcastMessages, Sentinal will automatically change it to InvokeCSharpEvents at runtime and log a warning. Update the setting in the inspector to avoid runtime changes.
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).
- ActionMapManager: Shows player count, “Action maps per view” (latest state per view selector, sorted by source), and per-player current action map with enabled maps list.
- Always use GameObject activation (
SetActive(bool)) for menu open/close operations. - Use
ICloseableViewfor menus that need custom close animations or specific menu closure. - Use
rootViewfor persistent UI elements like HUDs or a main menu screen (views that shouldn't be auto-closed but can still be hidden). - 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
ViewInputSystemHandlerusingActionMapConfigarrays to specify both action map names and their enabled/disabled state for when views are enabled or disabled. - Set
PlayerInput.notificationBehaviorto eitherInvokeCSharpEventsorInvokeUnityEventsin the inspector to avoid runtime warnings. - Use Default Action Maps on
ActionMapManagerto configure action maps that should be active when only root views (like HUD/main menu) are open. - SentinalManager static events are not cleared when a
SentinalManagerinstance is destroyed (e.g. on scene unload). Persistent subscribers (e.g.ActionMapManageron DontDestroyOnLoad) keep receiving view events from the new scene’s manager.




