Skip to content

Menus and HUD

MainScene's Canvas_UI has three root panels: MainMenu (MainMenuManager), Campaign (CampaignMenuUIManager) and Settings (SettingsManager). MenuNavigationManager shows one at a time, with history and transitions. Screens are found by component type, not by name, so you can rename and redesign them.

The game name is in MainMenu/Title ("Dungeon Crawler Template") and MainMenu/Subtitle ("Turn-Based FPS RPG"). They are not localized: edit them in the Inspector. Menu and pause backgrounds use an AspectRatioFitter set to Envelope Parent, so they cover any aspect ratio without distortion.

Add a menu screen

  1. Create a root panel with your own component (one type per screen).
  2. To refresh on open, implement IMenuScreen.OnMenuShown() on the same object.
  3. Add the panel to MenuNavigationManager.menuItems.
  4. Navigate with MenuNavigationManager.Instance.NavigateToMenu<MyScreen>() and GoBack().

Navigation requests during a transition are dropped.

Add a settings option

  1. Create the save key and field (see Save, settings and difficulty).
  2. Add a HorizontalSelector (Prefabs/Menu/SettingsOption) wired to SettingsManager.
  3. Make your system listen to SaveManager.ProfileChanged.
  4. Create the texts in the Settings table.

Warning

SettingsManager removes all listeners from the selectors and sliders it configures. Don't wire persistent events on them in the Inspector.

Loading screen

Prefabs/Menu/LoadingScreen.prefab shows a random background and a tip from the Hints table. Change scenes with LoadingScreen.Load("MyLevel"), LoadingScreen.Reload() or LoadingScreen.LoadMainMenu(). The scene must be in Build Settings.

In-level UI

Everything shown during a level is in Prefabs/Core/UILevel.prefab, controlled by GameManagerUI: the HUD, minimap, interaction prompt, boss bar, damage feedback, pause screen, death screen, end screen, shop, item inventory (Y), dialogue and toasts. References are serialized (nothing is found by name), so you can redesign the prefab as long as the Inspector references stay wired.

Note

The standalone Managers/GameManagerUI.prefab has empty references. Always use UILevel.prefab.

Photo mode

F2 hides or shows the whole CanvasUI for screenshots. It is not saved. Change the key in Photo Mode Key on GameManagerUI; set it to None to disable photo mode.

Show messages from code:

using AiasTech.Core.UI;

GameManagerUI.Instance?.ShowPickupToast("Armor +25", armorIcon);
GameManagerUI.Instance?.ShowPopupScreen("Secret found");

Add a modal panel

Implement IGameplayModal (Close()) and call GameplayModalGate.SetVisible(this, true/false) on open and close (including OnDisable). Esc then closes your panel instead of pausing, and the player can't act while it's open. Parent it to GameManagerUI.Instance.PanelsCanvas.

Pause

Toggle with GameStateManager.Instance.TogglePause(); listen to GameStateEvents.PauseChanged and GameStateEvents.DeathEntered.

Note

While paused, Time.timeScale is close to zero, not exactly zero. Use Time.unscaledDeltaTime for UI animations that must run while paused.

For internals, see Assets/DungeonCrawler/Scripts/Menu/ARCHITECTURE.md and Assets/DungeonCrawler/Scripts/Core/ARCHITECTURE.md.