Screens on layers, input routing, and keyboard, mouse, and gamepad selection for Unreal Engine.
Screens on layers, input routing, and keyboard, mouse, and gamepad selection for Unreal Engine.
NsUIFramework controls UI interaction for each local player. It opens and closes screens on three layers, decides which screen gets input, moves the selection with keyboard, mouse, and gamepad, and routes Confirm and Back. It also sets the input mode and the mouse cursor, so game code does not call SetInputMode. A HUD class opens start screens, and a second subsystem shows floating texts over world points.
NsUIFramework does not style widgets, animate screens, or show input prompt icons. It does not replicate: each machine shows its own UI.
Game, Menu, and Modal layers. Only the highest interactive screen gets input.UNsUIWidget as the parent, or implement INsUIScreen on any UUserWidget.AddToViewport takes part when it implements INsUIScreen.ANsUIHUD opens a list of screens when play starts.Unreal Engine 5.7+
NsUIFramework folder into the Plugins folder of your project."NsUIFramework" to the module dependencies in Build.cs.Blueprint:
NsUIWidget as the parent.Open Screen with a player controller, the widget class, and the layer Menu.Close Screen with the widget to close it, or push Back.C++:
#include "NsUISubsystem.h"
UNsUISubsystem* const UI = LocalPlayer->GetSubsystem<UNsUISubsystem>();
UUserWidget* const Screen = UI->OpenScreen(PauseMenuClass, Context, ENsUILayer::Menu);
UI->CloseScreen(Screen);
UI->CloseAll(ENsUILayer::Modal);
The subsystem owns the screens that OpenScreen makes. It keeps the context object alive until the screen closes.
To handle Confirm and Back, implement Handle Ns Screen Confirm and Handle Ns Screen Cancel in the screen. In C++, override HandleNsScreenConfirm_Implementation and HandleNsScreenCancel_Implementation. Return true when the screen uses the action.
| Layer | Use | Gameplay input with Automatic |
|---|---|---|
Game |
HUD parts that take input during play | Allowed |
Menu |
Menus such as pause or settings | Blocked |
Modal |
Popups such as confirmations | Blocked |
Modal comes first, then Menu, then Game. In one layer, the last screen to open has priority. Set bInteractive to false for prompts and toasts that take no input.
UNsUISubsystem β The local player subsystem: OpenScreen, CloseScreen, CloseAll, and FindScreen.UNsUIFunctionLibrary β Blueprint shortcuts from a player controller: OpenScreen, ToggleScreen, CloseScreen, GetUISubsystem.ANsUIHUD β A HUD that opens its StartScreens on BeginPlay.INsUIScreen β The screen contract. All events are optional.UNsUIWidget β A UUserWidget parent that implements INsUIScreen.FNsUIScreenConfig β The layer, bInteractive, the gameplay policy, and the selection mode class.GetNsScreenConfig β Return the config of the screen.OnNsScreenOpened / OnNsScreenClosed β Get the context and the selection mode, and release resources.OnNsScreenActivated / OnNsScreenSuspended β The screen gets input, or loses it but stays open.GetNsScreenSelection β Return automatic selection, a preferred target, or logical input.HandleNsScreenConfirm / HandleNsScreenCancel β Use Confirm or Back before the default action.UNsUIUMGSelectionMode β Native UMG focus and navigation. The default mode.UNsUIActorSelectionMode / UNsUILocationSelectionMode β Select actors or world points. In C++, call SetCandidates, then read GetSelectedActor or GetSelectedId.UNsUISelectionMode β The base class for a new kind of selection, in C++.UNsUIWorldPopupSubsystem β The local player subsystem: ShowPopup, ClearPopups, GetActivePopupCount.UNsUIWorldPopupWidget β The parent class of a popup widget. Its class defaults set the motion.ns.UI.Inspect β A read-only view of the screen stack, the selection, and the recovery reason. Editor only.ns.UI.SmokeTest.Toggle β A test screen with menus, modals, dynamic controls, actors, and locations. Editor only.Game layer.UNsUISelectionMode, and the actor and location modes take their candidates from C++ only.