fix(rendering): preserve managed SRP selection across scene replace

This commit is contained in:
2026-04-18 17:47:11 +08:00
parent cac6e34fa5
commit b8e84001fa
3 changed files with 64 additions and 3 deletions

View File

@@ -3389,8 +3389,9 @@ void MonoScriptRuntime::OnRuntimeStart(Components::Scene* scene) {
}
void MonoScriptRuntime::OnRuntimeStop(Components::Scene* scene) {
(void)scene;
ClearManagedRenderPipelineSelection(this);
if (scene != nullptr) {
ClearManagedRenderPipelineSelection(this);
}
ClearManagedInstances();
m_activeScene = nullptr;
GetInternalCallScene() = nullptr;

View File

@@ -155,12 +155,17 @@ void ScriptEngine::OnRuntimeSceneReplaced(Components::Scene* scene) {
return;
}
if (m_runtimeScene && m_runtimeSceneCreatedSubscription != 0) {
m_runtimeScene->OnGameObjectCreated().Unsubscribe(m_runtimeSceneCreatedSubscription);
m_runtimeScene->OnGameObjectCreated().ProcessUnsubscribes();
m_runtimeSceneCreatedSubscription = 0;
}
const float configuredFixedDeltaTime = m_runtimeFixedDeltaTime;
m_runtime->OnRuntimeStop(nullptr);
m_runtimeFixedDeltaTime = configuredFixedDeltaTime;
m_runtimeScene = scene;
m_runtimeSceneCreatedSubscription = 0;
m_scriptStates.clear();
m_scriptOrder.clear();