From 2b82da95117c80c6cd81d2c2fb45a1efe59f2f48 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 14 Mar 2024 17:29:10 +0100 Subject: [PATCH] Fix bug with null object being selected in prefab --- .../Editor/Windows/Assets/PrefabWindow.Selection.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs b/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs index cb4c7fd0f..be20c176c 100644 --- a/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs +++ b/Source/Editor/Windows/Assets/PrefabWindow.Selection.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; using System.Linq; -using FlaxEditor.Gizmo; using FlaxEditor.GUI.Tree; using FlaxEditor.SceneGraph; using FlaxEditor.SceneGraph.GUI; -using FlaxEditor.Viewport.Cameras; using FlaxEngine; namespace FlaxEditor.Windows.Assets @@ -64,8 +62,11 @@ namespace FlaxEditor.Windows.Assets private void OnSelectionUndo(SceneGraphNode[] toSelect) { Selection.Clear(); - Selection.AddRange(toSelect); - + foreach (var e in toSelect) + { + if (e != null) + Selection.Add(e); + } OnSelectionChanges(); } @@ -118,11 +119,13 @@ namespace FlaxEditor.Windows.Assets /// The nodes. public void Select(List nodes) { + nodes?.RemoveAll(x => x == null); if (nodes == null || nodes.Count == 0) { Deselect(); return; } + if (Utils.ArraysEqual(Selection, nodes)) return;