Fix error when actor from unloaded scene is selected

#486
This commit is contained in:
Wojtek Figat
2021-05-17 10:02:26 +02:00
parent 4b0967b45e
commit 4392e07cd6

View File

@@ -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<SceneGraphNode>();
for (int i = 0; i < selection.Count; i++)
{
if (selection[i].ParentScene != node)
newSelection.Add(selection[i]);
}
Editor.SceneEditing.Select(newSelection);
}
node.Dispose();
}
}