Download

Loading screen

Hi
I try to create function for loading level with displaying UMG Widget. But I do not Widget on screen during loading of level.
Game is frozen and next loaded level appears.


ULoader* ULoader::DoLoad(TSubclassOf<UUserWidget> uWidget, FName loadLevel, FName unloadLevel, UObject* WorldContextObject, FLatentActionInfo LatentInfo)
{
if (UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject))
{
UUserWidget* Widget = nullptr;

if (uWidget)
{
Widget = CreateWidget<UUserWidget>(World, uWidget);
Widget->AddToViewport();
}
if (loadLevel.IsValid())
{
UGameplayStatics::LoadStreamLevel(World, loadLevel, true, false, LatentInfo);
}
if (uWidget)
{
Widget->RemoveFromParent();
}
if(unloadLevel.IsValid())
UGameplayStatics::UnloadStreamLevel(World, unloadLevel, LatentInfo);
}
return NULL;
}


But if I use blueprint then everything works ok.
Blueprint:

Bam.

Good plugin.
I installed it. Delegate for PreLoadMap works OK.
but delegate for PostLoadMap does not work and during load level I do not see load screen.


#include "PlatformTester.h"
#include <Runtime/MoviePlayer/Public/MoviePlayer.h>
#include "MyGameInstance.h"

void UMyGameInstance::Init()
{
    UGameInstance::Init();

    FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UMyGameInstance::BeginLoadingScreen);
    FCoreUObjectDelegates::PostLoadMap.AddUObject(this, &UMyGameInstance::EndLoadingScreen);
}

void UMyGameInstance::BeginLoadingScreen()
{
    FLoadingScreenAttributes LoadingScreen;
    LoadingScreen.bAutoCompleteWhenLoadingCompletes = false;
    LoadingScreen.MinimumLoadingScreenDisplayTime = 5;
    LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();

    GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
    FString str = "TTT";
}

void UMyGameInstance::EndLoadingScreen()
{
    int32 p = 32;
}

Strange, should work fine.

You using this in Standalone or in PIE? PIE may not work.

After reloading UE4 load screen is started work. As I understood Load Screen works only for load game, but it does not work if I map is loaded by clicking button(“Start Game”).
Is some method for Load Screen if map if loaded by clicking button(“Start Game”) ?

Yeah it just binds to the Core Delegates, so as long as the level is opening it should work.

It may not work as expected in editor, try build out to standalone and trying that.