Reset bIsEditorModeActive on editor-PC EndPlay and SceneLoader entry
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -210,6 +210,20 @@ void APS_Editor_PlayerController::BeginPlay()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APS_Editor_PlayerController::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||||
|
{
|
||||||
|
// Reset the runtime-editor flag whenever this controller's world tears down — covers
|
||||||
|
// OpenLevel from any caller (Play button, scenario loader BP, gameplay code that calls
|
||||||
|
// OpenLevel directly), end of PIE, and seamless world transitions. Without this, the
|
||||||
|
// static would stay 'true' from the previous editor session and IsInEditorMode() would
|
||||||
|
// lie in the next world (which has no PS_Editor PlayerController). The 3 existing eager
|
||||||
|
// resets (CloseEditor + Play buttons) remain as defense-in-depth so any check between
|
||||||
|
// the click and the actual world tear-down also returns false.
|
||||||
|
UPS_Editor_SceneLoader::bIsEditorModeActive = false;
|
||||||
|
|
||||||
|
Super::EndPlay(EndPlayReason);
|
||||||
|
}
|
||||||
|
|
||||||
void APS_Editor_PlayerController::Tick(float DeltaTime)
|
void APS_Editor_PlayerController::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
virtual void OnPossess(APawn* InPawn) override;
|
virtual void OnPossess(APawn* InPawn) override;
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,13 @@ bool UPS_Editor_SceneLoader::LoadSceneFromData(UWorld* World, const FPS_Editor_S
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Defensive: reaching the gameplay-side SceneLoader means we are NOT in the runtime
|
||||||
|
// editor (the editor uses UPS_Editor_SceneSerializer instead). Force the static flag
|
||||||
|
// false now so subsequent IsInEditorMode() checks reflect reality even if a previous
|
||||||
|
// PIE session left the static at 'true' — PIE keeps C++ statics across stop/start, and
|
||||||
|
// a forced PIE-stop or BP-driven OpenLevel can skip the EndPlay reset on the editor PC.
|
||||||
|
bIsEditorModeActive = false;
|
||||||
|
|
||||||
// Apply the scenario's dynamic-navigation flag BEFORE spawning actors. If the scenario
|
// Apply the scenario's dynamic-navigation flag BEFORE spawning actors. If the scenario
|
||||||
// needs runtime nav generation, switching the level's RecastNavMesh to Dynamic now
|
// needs runtime nav generation, switching the level's RecastNavMesh to Dynamic now
|
||||||
// means the actors we're about to spawn will dirty + rebuild tiles around them. Cooked
|
// means the actors we're about to spawn will dirty + rebuild tiles around them. Cooked
|
||||||
|
|||||||
Reference in New Issue
Block a user