A loading screen
This guide builds a loading screen in UMG: it covers the screen while the player waits, shows a
progress bar and what is loading ("Loading the arena (37/120)"), and goes away when everything,
including your own setup, is done. The example project's WBP_YR_LoadingScreen is a finished
one, created by its BP_YR_GameState.
It needs Gantry's asset manager as the project's asset manager (Getting Started).
1. The widget
Create a Widget Blueprint, WBP_LoadingScreen, with a full-screen background, a Progress
Bar and a Text block.
In its graph, on Event Tick (or a timer, a few times a second):
- Get the Gantry Streaming Subsystem (an engine subsystem: search for it in the graph's context menu).
- Get Overall Progress into the progress bar's percent. It runs from 0 to 1 across every load the player waits on.
- Get Primary Scope, break it, and build the text from Debug Name, Loaded Count and Requested Count: "Loading the arena (37/120)".
- If Should Show Loading Screen is false, Remove from Parent: loading is done.
2. Showing it
Each world creates its own: in your GameState or PlayerController's Begin Play, on the machine
with a local player, Create Widget WBP_LoadingScreen and Add to Viewport with a high Z
order, so it sits above the HUD. It covers the screen from the first frame, and removes itself
when Gantry says the wait is over.
Should Show Loading Screen is true while:
- a load the player waits on is open, such as an experience's stages loading;
- the game is travelling to a map;
- something holds the screen up (step 3).
On Loading Screen Changed fires whenever that answer changes, if you would rather react than check every tick.
3. Holding it up for your own reasons
Gantry knows about its own loads. Your game may have more to wait for: a character still being set up, a player state still arriving over the network, an intro fade.
- Hold Loading Screen with a reason, then Release Loading Screen Hold with the handle it returned when done.
- Or implement the Gantry Loading Hold interface on the object that is not ready, and register it with Add Loading Hold. Gantry asks it every frame whether to keep holding, until it says no, is removed, or is destroyed.
Get Loading Screen Reasons lists, one line each, why the screen is up. Show it on screen while you build this, and you will see exactly what is being waited for.
4. Making the progress honest
The screen only sees loads that go through Gantry. Load your own assets with Load Assets Tracked or Load Primary Assets Tracked instead of Load Asset, and give each a name the player understands. Avoid Load Synchronous and hard asset references for anything big: those loads are invisible, and the screen can say "done" while the game still hitches. Turn on Warn On Blocking Loads in Project Settings > Plugins > Gantry Gauge to find them, and watch the Load Gauge panel (Tools > Gantry) while you play.
About map travel
A widget belongs to its world, so travelling to a new map removes it, and the new world creates its own when it begins play. To also cover the moment of travel itself, start the engine's movie player loading screen when On Loading Screen Changed reports that a map travel has begun; Gantry raises it early enough for that. The movie player is set up from C++ (or a loading screen plugin).
Next
- List everything that loaded, nested as it happened: Start Load Recording and Get Load Recording.
- Show which experience step is running: Get Current Stage Name and Get Stage Progress on the experience subsystem.