From 4392e07cd64ed62e56edaf0b58f2ba657cba667b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 17 May 2021 10:02:26 +0200 Subject: [PATCH] Fix error when actor from unloaded scene is selected #486 --- Source/Editor/Modules/SceneModule.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/Editor/Modules/SceneModule.cs b/Source/Editor/Modules/SceneModule.cs index 86479b696..0b4206526 100644 --- a/Source/Editor/Modules/SceneModule.cs +++ b/Source/Editor/Modules/SceneModule.cs @@ -414,6 +414,26 @@ namespace FlaxEditor.Modules Editor.Log($"Cleanup graph for scene \'{scene.Name}\'"); // Cleanup + var selection = Editor.SceneEditing.Selection; + var hasSceneSelection = false; + for (int i = 0; i < selection.Count; i++) + { + if (selection[i].ParentScene == node) + { + hasSceneSelection = true; + break; + } + } + if (hasSceneSelection) + { + var newSelection = new List(); + for (int i = 0; i < selection.Count; i++) + { + if (selection[i].ParentScene != node) + newSelection.Add(selection[i]); + } + Editor.SceneEditing.Select(newSelection); + } node.Dispose(); } }