diff --git a/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp b/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp index c64a8dc..50962bc 100644 --- a/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp +++ b/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp @@ -163,7 +163,10 @@ ULoadingScreenWidget *ULoadingScreenManager::ShowLoadingScreen() UGameViewportClient *GameViewportClient = LocalGameInstance->GetGameViewportClient(); GameViewportClient->AddViewportWidgetContent(this->LoadingScreenWidget.ToSharedRef(), Settings->LoadingScreenZOrder); - this->ChangePerformanceSettings(/*bEnableLoadingScreen=*/ true); + // After the load screen is fully loaded in, change the performance settings. We delay + // this because one of the performance settings disables 3D rendering, which we don't + // want to do until the load screen is completely obscuring that fact. + this->LoadingScreenUMGWidget->OnLoadScreenOpened.AddLambda([this]{ this->ChangePerformanceSettings(/*bEnableLoadingScreen=*/ true); }); if (!GIsEditor || Settings->ForceTickLoadingScreenEvenInEditor) { @@ -196,7 +199,7 @@ void ULoadingScreenManager::HideLoadingScreen_Private() { this->ChangePerformanceSettings(/*bEnableLoadingScreen=*/ false); - this->LoadingScreenUMGWidget->OnLoadScreenClosed.BindUObject(this, &ULoadingScreenManager::RemoveLoadingScreen); + this->LoadingScreenUMGWidget->OnLoadScreenClosed.AddUObject(this, &ULoadingScreenManager::RemoveLoadingScreen); this->LoadingScreenUMGWidget->BeginFadeOut(); } } @@ -211,8 +214,8 @@ void ULoadingScreenManager::RemoveLoadingScreen() this->StopBlockingInput(); this->RemoveWidgetFromViewport(); - this->LoadingScreenUMGWidget->OnLoadScreenOpened.Unbind(); - this->LoadingScreenUMGWidget->OnLoadScreenClosed.Unbind(); + this->LoadingScreenUMGWidget->OnLoadScreenOpened.Clear(); + this->LoadingScreenUMGWidget->OnLoadScreenClosed.Clear(); // Let observers know that the loading screen is done this->LoadingScreenVisibilityChanged.Broadcast(/*bIsVisible=*/ false); @@ -256,26 +259,26 @@ void ULoadingScreenManager::StopBlockingInput() } } -void ULoadingScreenManager::ChangePerformanceSettings(bool bEnabingLoadingScreen) +void ULoadingScreenManager::ChangePerformanceSettings(bool bEnableLoadingScreen) { UGameInstance *LocalGameInstance = this->GetGameInstance(); UGameViewportClient *GameViewportClient = LocalGameInstance->GetGameViewportClient(); - FShaderPipelineCache::SetBatchMode(bEnabingLoadingScreen ? FShaderPipelineCache::BatchMode::Fast : FShaderPipelineCache::BatchMode::Background); + FShaderPipelineCache::SetBatchMode(bEnableLoadingScreen ? FShaderPipelineCache::BatchMode::Fast : FShaderPipelineCache::BatchMode::Background); // Don't bother drawing the 3D world while we're loading - GameViewportClient->bDisableWorldRendering = bEnabingLoadingScreen; + GameViewportClient->bDisableWorldRendering = bEnableLoadingScreen; // Make sure to prioritize streaming in levels if the loading screen is up if (UWorld* ViewportWorld = GameViewportClient->GetWorld()) { if (AWorldSettings *WorldSettings = ViewportWorld->GetWorldSettings(false, false)) { - WorldSettings->bHighPriorityLoadingLocal = bEnabingLoadingScreen; + WorldSettings->bHighPriorityLoadingLocal = bEnableLoadingScreen; } } - if (bEnabingLoadingScreen) + if (bEnableLoadingScreen) { // Set a new hang detector timeout multiplier when the loading screen is visible. double HangDurationMultiplier; diff --git a/Source/CommonLoadingScreen/Public/LoadingScreenManager.h b/Source/CommonLoadingScreen/Public/LoadingScreenManager.h index 29738b3..42577a9 100644 --- a/Source/CommonLoadingScreen/Public/LoadingScreenManager.h +++ b/Source/CommonLoadingScreen/Public/LoadingScreenManager.h @@ -61,7 +61,7 @@ private: /** Resumes in-game input, if blocking */ void StopBlockingInput(); - void ChangePerformanceSettings(bool bEnabingLoadingScreen); + void ChangePerformanceSettings(bool bEnableLoadingScreen); private: /** Delegate broadcast when the loading screen visibility changes */