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) <noreply@anthropic.com>
This commit is contained in:
@@ -589,9 +589,10 @@ TSharedRef<SWidget> UPS_Editor_MainWidget::BuildSceneButtons()
|
|||||||
|
|
||||||
// Store scene name in GameInstance subsystem (survives OpenLevel)
|
// Store scene name in GameInstance subsystem (survives OpenLevel)
|
||||||
FString BaseLevel = EditorPC->CurrentBaseLevel;
|
FString BaseLevel = EditorPC->CurrentBaseLevel;
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("PS_Editor Play: BaseLevel='%s'"), *BaseLevel);
|
||||||
if (BaseLevel.IsEmpty())
|
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();
|
return FReply::Handled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,11 +612,16 @@ TSharedRef<SWidget> 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->bShowMouseCursor = false;
|
||||||
EditorPC->SetInputMode(FInputModeGameOnly());
|
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();
|
return FReply::Handled();
|
||||||
})
|
})
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user