Skip to main content

Common Loading Screen

A plugin included with Lyra. The plugin helps manage a custom loading screen for your game. The plugin can be obtained from downloading Lyra through FAB or taking it from the Samples/Lyra section of the Unreal Engine repo, found here

Unreal Engine Repo: Plugins/CommonLoadingScreen

Creating a loading screen Widget

First, create a widget that can hold the logic we need. It's simple logic to update the loading screen with our current loading state.

Create a widget blueprint that inherits ULoadingScreenHost and add a UCommonTextBlock as the binding wants.

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "LoadingScreenHost.generated.h"

UCLASS(Abstract)
class GAME_API ULoadingScreenHost : public UUserWidget
{
GENERATED_BODY()

protected:
void NativeOnInitialized() override;
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;

private:
UPROPERTY(EditAnywhere)
FText DefaultLoadingText;

UPROPERTY(meta = (BindWidget))
class UCommonTextBlock* LoadReasonTextBlock;

TWeakObjectPtr<class ULoadingScreenManager> LoadingScreenManager;
};

Updating the Plugin config

Set your newly created widget blueprint as the value of LoadingScreenWidget in the settings. Once done, you can try playing in editor and changing between levels in your game and the screen will show.

Note: to use "Hold Loading Screen Additional Secs" in the editor, you must check the box "Hold Loading Screen Additional Secs Even In Editor"

Custom loading messages

Not only does the plugin manage showing/hiding your loading screen, you can also specify custom rules for when the loading screen shows.

The manager has a set of logic for iterating through things to determine if they implement ILoadingProcessInterface so do check the logic first.

Example: Player Controller Component

The code below works assuming you're adding this player controller component to your custom player controller externally

#pragma once

#include "CoreMinimal.h"
#include "LoadingProcessInterface.h"
#include "Components/ControllerComponent.h"
#include "DelayedPlayerControllerComponent.generated.h"

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class GAME_API UDelayedPlayerControllerComponent : public UControllerComponent, public ILoadingProcessInterface
{
GENERATED_BODY()

public:
//~ILoadingProcessInterface interface
bool ShouldShowLoadingScreen(FString& OutReason) const override;
//~End ILoadingProcessInterface interface

protected:
void BeginPlay() override;

void OnDelayComplete();

private:
FTimerHandle DelayTimerHandle;
bool bIsLoading = false;
};