Orion Orion Loading ScreenManual
中文EN

C++ integration

Add OrionLoadingScreen to the dependencies of your module's Build.cs, and to the Plugins list of your .uplugin when the code lives in a plugin. All calls run on the game thread. The subsystem does not exist on a dedicated server, so always check the result of GetSubsystem:

On this page
C++
#include "OrionLoadingScreenSubsystem.h"

UOrionLoadingScreenSubsystem* LoadingScreen = GetGameInstance()->GetSubsystem<UOrionLoadingScreenSubsystem>();

Loading participants

Implement IOrionLoadingParticipant on the GameState, a local PlayerController, its Pawn, or a component of any of them; the subsystem finds those by itself. Any other object registers with RegisterParticipant and unregisters with UnregisterParticipant when it is done or destroyed.

C++
#include "OrionLoadingParticipant.h"

UCLASS()
class UMyMatchSetupComponent : public UActorComponent, public IOrionLoadingParticipant
{
	GENERATED_BODY()

public:
	virtual bool GetLoadingStatus(FOrionLoadingStatus& OutStatus) const override
	{
		if (bReady)
		{
			return false;
		}
		OutStatus.Stage = TEXT("match_setup");
		OutStatus.Milestone = EOrionLoadingMilestone::World;
		OutStatus.Progress = LoadedFraction;
		OutStatus.DebugReason = TEXT("Match setup is loading its content");
		return true;
	}

private:
	float LoadedFraction = 0.0f;
	bool bReady = false;
};

GetLoadingStatus returns true while the object is not ready and fills one status:

Field Meaning
DebugReason Required. Goes to the log only.
Stage, Milestone Stage key and the progress step its progress fills: World for world content such as game mode setup or catalogs, Player for player data, admission or the HUD, None for work that only shows a status. An empty stage takes the default of where the participant was found.
Progress Real completed share in [0, 1]. Leave it unset when the total is unknown, cancelled or finished.
Text Text the player sees; empty shows the stage text.
Presentation Screen selected while this participant keeps the loading screen up.

Participants are queried every frame. Keep the checks cheap and free of side effects.

Tasks

UOrionLoadingTask is a participant for work that has no natural owner object, and the way Blueprint reports loading. Keep it in a UPROPERTY and call Finish on success, failure, cancellation and EndPlay; a task that is no longer referenced stops counting.

C++
LoadingTask = UOrionLoadingTask::BeginLoadingTask(this, TEXT("Loading the inventory icons"));
TSharedPtr<FStreamableHandle> Handle = UAssetManager::GetStreamableManager().RequestAsyncLoad(Paths, FStreamableDelegate::CreateUObject(this, &ThisClass::OnIconsLoaded));
if (LoadingTask)
{
	LoadingTask->TrackLoad(TEXT("inventory"), EOrionLoadingMilestone::Player, Handle);
}

TrackLoad reads the progress of the streamable handle weakly and stops reporting once it is cancelled or released. SetProgress reports a stage with a fixed share, or with an unknown one when the share is negative; SetStatusText, SetPresentation and SetDebugReason fill the rest of the status. FinishLoadingTasks(DebugReason) finishes every task with that exact reason, for a host that bounds optional work with its own budget.

Loading operations

C++
FOrionLoadingOperationRequest Request;
Request.Destination = TEXT("/Game/Maps/Arena");
Request.bTravel = true;
Request.bWaitForOwnerCompletion = true;
OperationHandle = LoadingScreen->BeginLoadingOperation(this, Request);

// After the server accepted the request:
LoadingScreen->CompleteLoadingOperation(OperationHandle);

BeginLoadingOperation presents the screen right away, so call it before you tear down the current UI or start a synchronous map change. A child step joins the running operation through Request.ParentOperation; a stale parent is rejected and returns an invalid handle. GetLoadingOperation returns the current operation, including its normalized destination map, mode, context and progress. NormalizeDestinationMap turns a map package or a travel URL into the same lower-case long package name without loading anything.

Startup holds

C++
LoadingScreen->AddStartupHold(this);
// When the work is done, or in EndPlay:
LoadingScreen->RemoveStartupHold(this);

Holds are weak, so a destroyed holder releases itself. RestartStartup enters startup again; HasPlayedStartupIntro and MarkStartupIntroPlayed track the intro across restarts.

Shader precompilation

BeginShaderPrecompile resumes PSO batching; the cache compiles in fast batches until the precompilation ends. GetShaderPrecompileProgress returns the finished share and never decreases, GetShaderPrecompileCounts returns the finished and seen precompiles, HasPendingShaderPrecompiles tells whether anything is left, and OnShaderPrecompileFinished fires once the started precompilation has ended. The built-in shader compilation screen uses exactly these calls.

Blocking the game thread

Before an operation that blocks the game thread, such as a synchronous load, ask for the screen to be presented first:

C++
PreparationHandle = LoadingScreen->PrepareForBlockingOperation(
	FSimpleDelegate::CreateUObject(this, &ThisClass::RunBlockingWork),
	FSimpleDelegate::CreateUObject(this, &ThisClass::RunBlockingWork));

Here the work runs either way; a failed preparation only means the player sees the last frame instead of the screen. OnReady fires once the screen has been on screen for a frame. The built-in presenter calls OnFailed when the screen cannot appear within five seconds, and calls OnReady immediately when there is no game viewport. CancelBlockingPreparation drops a pending request without calling it. Blueprint uses the Wait For Loading Screen node for the same purpose, and a widget that draws asynchronously holds the preparation with Hold Presentation until it calls Release Presentation.

Game exit

PrepareGameExit(OnReady, OnFailed) shows the exit screen (bExiting in the widget state) and keeps it until CancelGameExit or shutdown, so the world can tear down behind it. OnReady runs once the exit screen is presented; OnFailed runs when the presenter fails or the screen is still not presented after Game Exit Presentation Timeout Seconds. Both only report the screen, so continue the exit from either one. Call CancelGameExit with the returned handle when the exit was rejected, for example by a confirmation dialog.

Events

Event Fires
OnVisibilityChanged() After the screen was shown or hidden; observers already see the new state.
OnHandoffChanged() When the handoff starts or is revoked.
OnLoadingFinished() Once per loading when nothing requires or holds the screen any more; startup holds and the presenter's fade-out may still keep it.
OnAnyKey() For each key, mouse button or wheel step released while the screen covers the game.
OnShaderPrecompileFinished() Once when the started precompilation has ended.

Custom presenters

The subsystem owns every loading decision; a presenter only draws. To show something completely different, such as a web page or a video, derive from UOrionLoadingScreenPresenter and select the class in Presenter Class. A class that cannot be loaded falls back to the built-in presenter.

Hook Contract
Initialize, Deinitialize Once each. Release every resource and callback in Deinitialize.
Tick Every frame, after the subsystem updated the loading state.
OnStartupRestarted RestartStartup entered startup again. Reset your startup sequence here; the next readiness check already asks NeedsLoadingScreen.
CreateLoadingScreenWidget Slate widget added to the game viewport at Z Order when the screen shows. Null keeps an opaque black cover.
OnLoadingScreenShown, OnLoadingScreenHidden After the screen entered the viewport, before it leaves.
NeedsLoadingScreen Keeps the screen up for the presenter's own work, such as startup screens or a blocking preparation; delays OnLoadingFinished.
ShouldRenderWorld Returns true while the world should render behind the visible screen. The subsystem is the only writer of bDisableWorldRendering and always renders the world during the handoff and the texture streaming wait. The default renders during startup.
CanDismissLoadingScreen Called every frame during the handoff; return false until an exit animation has finished.
CreateMapLoadingWidget, OnMapLoadingFinished A synchronous map load blocks the game thread, and the subsystem lets MoviePlayer draw the widget you return. It must be pure Slate: no UMG and no game-thread state. OnMapLoadingFinished follows once MoviePlayer stopped.
CreateConnectionStatusWidget Hint shown while a connection has not identified its destination.
PrepareForBlockingOperation, CancelBlockingPreparation See blocking the game thread.
OnGameExitStarting, OnGameExitCanceled Around a game exit request.
ResolveDestinationContext Fills the mode and context of a destination URL for your content choice.
ShouldSuppressLoadingScreen Keeps a host state such as a failure dialog visible; the current loading is canceled, not completed.

FOrionViewportSnapshot keeps the last composed frame of a viewport area on the GPU and draws it as pure Slate. Call ObserveViewport every frame with the game viewport's window and area, Freeze and return GetWidget from CreateMapLoadingWidget, then Release in OnMapLoadingFinished. It records just before each present and never reads back to the CPU.

Type two or more characters

Contact us

Questions about the plugin, purchases or partnerships? Send us an email.