From a91aac11923865dadd7f1ddf6038deb090859065 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Sun, 12 Apr 2026 18:35:52 +0200 Subject: [PATCH] Fix Play button: unload sublevel + use full map path for OpenLevel OpenLevel("test") was resolving to the streamed sublevel instance (test_LevelInstance_5) instead of the actual map. Fix: - Unload sublevel via LoadBaseLevelAsSublevel("None") before OpenLevel - Use full path "/Game/{BaseLevel}" to avoid ambiguity Also: all widget lambdas now get SpawnManager/SceneSerializer fresh from PlayerController (critical fix for packaged builds where weak ptrs are null). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp index 52724cc..201df7c 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp @@ -589,9 +589,10 @@ TSharedRef UPS_Editor_MainWidget::BuildSceneButtons() // Store scene name in GameInstance subsystem (survives OpenLevel) FString BaseLevel = EditorPC->CurrentBaseLevel; + UE_LOG(LogTemp, Warning, TEXT("PS_Editor Play: BaseLevel='%s'"), *BaseLevel); if (BaseLevel.IsEmpty()) { - UE_LOG(LogTemp, Warning, TEXT("PS_Editor: No BaseLevel set, cannot Play. CurrentBaseLevel is empty.")); + UE_LOG(LogTemp, Warning, TEXT("PS_Editor: No BaseLevel set, cannot Play.")); return FReply::Handled(); } @@ -611,11 +612,16 @@ TSharedRef UPS_Editor_MainWidget::BuildSceneButtons() } } - // Reset input mode before transition so the target GameMode starts clean + // Unload sublevel before OpenLevel to avoid name conflict + EditorPC->LoadBaseLevelAsSublevel(TEXT("None")); + + // Reset input mode before transition EditorPC->bShowMouseCursor = false; EditorPC->SetInputMode(FInputModeGameOnly()); - UGameplayStatics::OpenLevel(EditorPC, FName(*BaseLevel), true, TEXT("")); + // Use full path to avoid confusion with sublevel instances + FString MapPath = FString::Printf(TEXT("/Game/%s"), *BaseLevel); + UGameplayStatics::OpenLevel(EditorPC, FName(*MapPath), true, TEXT("")); return FReply::Handled(); }) [