Your Own Screen
When the style is not enough, bring your own loading screen: a native Slate view in C++, or a UMG widget made in the designer.
Neo Async Loading Screen draws its own loading screen, styled by the recipe, in a game on its own thread on Direct3D 12, Windows 64-bit, while the engine loads. The two ways to bring yours differ in one thing that matters a lot: what happens while the game thread is blocked, which is most of a map load.
| Native Slate view | UMG widget | |
|---|---|---|
| Recipe | screen { widget native MyStudioView } | screen { widget "/ and engine { thread off } |
| Made in | C++ (a Slate widget) | the UMG designer (a Widget Blueprint) |
| While the game thread is blocked (LoadMap, a long spawn) | painted by Neo Async Loading Screen's own thread, on Direct3D 12 (not with texts in Arabic, Hebrew, Thai or a script of India: HLP406) | frozen: nothing paints it until the game thread is back |
| Units | the look's unit: 1 unit = 1 pixel at 1080p, at every resolution | UMG's own (your project's DPI curve) |
| Fades, floor, mouse | yours to paint | done for you (the style's fades and opaque floor, the mouse stopped) |
| Rules | the native view contract below | UMG's own, and the few lines below |
Pick a native view when the screen must go on drawing while the engine loads. Pick UMG when your team designs in UMG and a frozen frame during the heaviest part of a load is acceptable: it is the price of UMG, not a defect. The default view of the plugin is a native view.
A UMG loading screen
- Create a Widget Blueprint whose parent class is Neo Async Loading Screen User Widget (
UNeo).Loading Screen User Widget - Read the screen with its functions, in bindings or in the graph:
Get Level Name,Get Tip,Get Status,Get Image BrushandHas Image,Get Elapsed Seconds,Get Kind,Get Loading Phase,Get Progress(negative when the game reports none; the plugin itself never shows a progress). Two events:On Loading Started(the widget was just made for a screen) andOn Loading Finishing(the screen begins to fade out, or ends without a fade). - Or name widgets of the designer
LevelNameText,TipText,StatusText(Text Blocks) andBackdropImage(an Image): they are filled every frame, nothing to bind. For the image with its style's life (its slow drift, the style's vignette, grain, glows and slow motion, as the plugin's own screen draws it: Recipes, Bringing the image to life), add a Neo Async Loading Screen Backdrop (UNeo) namedLoading Screen Backdrop Backdropinstead of the Image. It draws no plate under your texts, and its Render Opacity dims it. - Choose it in a recipe (
Config/or a recipe asset):Neo Loading Screen/ *. hload
hload 1
screen {
widget "/Game/UI/WBP_Loading"
}
engine {
thread off
}Without engine { thread off } the recipe is refused (HL431) and the default view is shown: a UMG widget draws on the game thread only, and the screen's own thread never shows one.
The plugin ships a sample made by script, / (the Backdrop and the three texts over a full-screen overlay, and a throbber the game thread animates): point a recipe at it to try UMG, or duplicate it.
Scroll the graph sideways.
Cooking. Nothing in your maps references the widget: the editor module adds to the cook every asset a recipe of the project names (Project Settings, Config/, the recipe assets), the widget included. A widget named only by a recipe made at run time is not cooked: reference it from something cooked (a Primary Asset, a map, your game instance), or add its folder to Project Settings > Packaging > Additional Asset Directories to Cook.
The very first screen. The plugin loads the widget's class in advance and asynchronously, as soon as the recipe names it, when the game instance starts (before the engine's first map load); nothing is ever loaded synchronously when a screen shows. The first map load of the launch begins right after, so its screen nearly always comes before the class is loaded, and shows the default view (HLP480), in your style. If that screen must be yours too, have the class in memory before the game instance starts: a hard reference from your Game Instance class (the engine loads that class, and what it references, before anything else of the game), never a reference from the startup map (the map is loaded after its screen is made).
What the plugin does for a UMG screen:
- it makes one widget per screen, on the game instance, in the game layer above every other widget of the game;
- it paints the style's opaque floor under the widget (the level never shows through), fades the whole in and out with the style's curves and the player's Reduce Motion, and stops the mouse while the screen covers the game;
On Loading Finishingcomes when the fade out begins, or just before the widget goes when the screen ends without a fade (another system's screen took over). A new load during the fade cancels it: the screen covers again, with the same widget (Get Loading Phaseis no longer Closing), andOn Loading Finishingcomes again when the screen really closes. Play your exit so that it can be undone;On Loading Started,On Loading Finishingand the widget'sConstructmay call the plugin back (Show Loading Screen, Hide Loading Screen, Add or Remove Loading Screen Hold, Open Level Behind Loading Screen): the call is carried out once what the plugin was doing is over, before the call that ran your event returns. A screen shown fromOn Loading Finishingis a new screen of its own;- each screen without the presenter's thread says so in the log, with its cause:
Neo Async Loading Screen: thread off umg widget /.Game/ UI/ WBP_ Loading: the game thread draws this screen (engine { thread off })
When the widget cannot be shown, the default view is, and the log says why, once per widget and reason (each code has its entry in Troubleshooting):
| Code | Cause | Fix |
|---|---|---|
| HLP480 | the class is not loaded yet | it loads in the background; for the first screen of the launch, see above |
| HLP481 | the class is not a usable Neo Async Loading Screen User Widget (another class, an abstract one) | reparent the Widget Blueprint |
| HLP482 | the presenter's thread is on for this screen | write engine { thread off } |
| HLP483 | not the path of a Widget Blueprint | write widget "/ |
| HLP485 | Create Widget gave nothing | see the lines before it in the log |
| HLP486 | the class could not be loaded: no such asset, or it was not cooked | check the path; see Cooking above |
A native Slate view
Register a factory from your module (its StartupModule), remove it at Shutdown. Your module's Build.cs names Neo (and the engine's Slate, SlateCore), nothing else of the plugin:
#include "NeoLoadingScreenViews.h"
FNeoLoadingScreenViews::SetViewFactory(TEXT("MyStudioView"), [](const FNeoLoadingScreenViewArgs& Args)
{
return SNew(SMyStudioLoadingView, Args);
});and choose it in a recipe with screen { widget native MyStudioView }.
The same factory makes the instance the game thread paints (the game layer) and the instance Neo Async Loading Screen's own thread paints while the game thread is blocked. Both get the same source, the same start and the same clock, and the plugin lays both out at the same scale: the look's unit, 1 unit = 1 pixel at 1080p (the style's Interface Size included), whatever the resolution and whatever the DPI curve of your project. Write your view in Slate units as usual: it fills 1920 x 1080 units on a 16:9 screen at any resolution, and both instances paint the same pixels at the same instant, so passing from one to the other changes nothing on screen.
The contract of a native view, which the plugin cannot check for you:
- the factory runs on the game thread, once per presentation (each time the plugin's thread starts presenting a screen, and each time the game layer shows it), so one screen may make several instances: build everything there (fonts, brushes, sizes), and keep no state of your own across instances: what the view shows comes from the source and the clock, never from how long the instance has lived;
- after that, the view reads no UObject, no game state and no engine global; only
Args.Source(GetLook,GetState, safe from any thread),Args.andStart Seconds Args.Now(); OnPaint,Tickand layout are safe on another thread: never wait for the game thread, never take a lock it may hold, never rasterize new glyphs (shape your texts while the view is built);- time comes from
Args.Now(), never from frame counts or the engine's delta time; - it is opaque: every pixel of its geometry, every frame (the level must never show through);
- if it draws the status line (
Compose), it says so inNeo Loading Screen Status Line(State, Now) OnPaint:Note. The line then keeps its pace on screen even when a frame comes late; without it, the pace counts from the moment each change is published;Neo Loading Screen Status Drawn(Args. Source. To Shared Ref(), State. Engine. Serial At(Now), Now) - it is destroyed on the game thread.
The launch screen (from the start of the process to the end of the first map's load) always shows the default view, in your style: the plugin's thread covers the launch before your module registers its view, and one screen keeps one look. Your view shows from the next screen on.
Without a factory under the recipe's name, the default view is shown and the log says so once (HLP484).
Choosing, in short
- The screen must go on drawing while the engine loads (the reason this plugin exists): the default view with your style, or a native view.
- Your screen is a UMG design and a frozen frame while the engine loads is fine: UMG, with
engine { thread off }. - Never both on one screen: one look per screen, the same in every surface.
Something not as described? Every code the editor or the log shows has its own entry in Troubleshooting.