Skip to content

Getting started

Fastest way to get started

  1. Open Assets/LevelArgento/SmartUINavigation/Samples/QuickStart/QuickStart.unity.
  2. Enter Play Mode.
  3. Navigate with the keyboard or a gamepad. PLAY receives focus automatically.
  4. Inspect the UI Manager GameObject and its Focus Manager and Input Mode Detector components.
  5. Inspect the Main Menu GameObject and its Focus Scope component.
  6. Use the same component structure in your own uGUI menu.

The Quick Start sample intentionally uses Unity Automatic navigation for its three-button vertical menu. The other included samples demonstrate smart directional navigation, dynamic content, modal restoration, and more advanced focus flows.

Set up an existing menu

This setup adds default focus, selection memory, and invalid-selection recovery to an existing uGUI menu.

  1. Configure one active EventSystem with InputSystemUIInputModule and your enabled UI actions.
  2. Add the Focus Manager (SmartFocusManager) component to a scene object and assign its Event System field.
  3. Add the Focus Scope (SmartFocusScope) component to the root of a menu or panel.
  4. Assign a valid child Selectable to Default Selection.
  5. Leave Remember Last Selection enabled if returning to the menu should restore its last valid selection.
  6. Assign the scope to the manager's Initial Scope, or call SetScope when the menu opens.
  7. For mouse-aware focus recovery, add the Input Mode Detector (SmartInputModeDetector) component and assign it to the Focus Manager's Input Mode Detector field. Leave Input Source at Auto (EventSystem); no manual action assignments are needed.
  8. Enter Play Mode and test with keyboard and gamepad navigation.
Input Mode Detector Inspector in Auto (EventSystem) mode, showing resolved UI actions
In Auto mode, the detector displays the actions resolved from the EventSystem's InputSystemUIInputModule.

The scope and its default control must be active when focus is requested.

Switching menus from code

using LevelArgento.SmartUINavigation;
using UnityEngine;

public sealed class MenuController : MonoBehaviour
{
    [SerializeField] private SmartFocusManager focusManager;
    [SerializeField] private GameObject optionsPanel;
    [SerializeField] private SmartFocusScope optionsScope;

    public void OpenOptions()
    {
        optionsPanel.SetActive(true);
        focusManager.SetScope(optionsScope);
    }

    public void CloseOptions()
    {
        focusManager.SetScope(null);
        optionsPanel.SetActive(false);
    }
}

SetScope(null) stops monitoring a scope but does not itself clear or change the EventSystem selection. If another menu opens, activate it and call SetScope with its scope.

Requesting a specific selection

using LevelArgento.SmartUINavigation;
using UnityEngine;
using UnityEngine.UI;

public sealed class FocusShortcut : MonoBehaviour
{
    [SerializeField] private SmartFocusManager focusManager;
    [SerializeField] private Button target;

    public void FocusTarget()
    {
        focusManager.RequestFocus(target);
    }
}

RequestFocus returns false if the target is outside the current scope, inactive, disabled, or non-interactable.

Optional smart navigation

For menus that need generated directional links, add the Navigation Group (SmartNavigationGroup) component to a common ancestor of the participating controls. It rebuilds after layout and hierarchy changes by default. See smart navigation before applying it to an existing navigation setup, because rebuilding writes Navigation.Mode.Explicit links.