diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index 8c3c26e54..5d0859afe 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -235,8 +235,9 @@ namespace FlaxEditor.Content.GUI /// /// The items to show. /// The sort method for items. - /// If set to true items will be added to the current selection. Otherwise selection will be cleared before. - public void ShowItems(List items, SortType sortType, bool additive = false) + /// If set to true items will be added to the current list. Otherwise items list will be cleared before. + /// If set to true selected items list will be preserved. Otherwise selection will be cleared before. + public void ShowItems(List items, SortType sortType, bool additive = false, bool keepSelection = false) { if (items == null) throw new ArgumentNullException(); @@ -253,6 +254,7 @@ namespace FlaxEditor.Content.GUI // Lock layout var wasLayoutLocked = IsLayoutLocked; IsLayoutLocked = true; + var selection = !additive && keepSelection ? _selection.ToArray() : null; // Deselect items if need to if (!additive) @@ -265,6 +267,11 @@ namespace FlaxEditor.Content.GUI items[i].Parent = this; items[i].AddReference(this); } + if (selection != null) + { + _selection.Clear(); + _selection.AddRange(selection); + } // Sort items depending on sortMethod parameter _children.Sort(((control, control1) => diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 6415db889..884187f8c 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -739,12 +739,12 @@ namespace FlaxEditor.Windows items.Add(node.Folder); } } - _view.ShowItems(items, _sortType); + _view.ShowItems(items, _sortType, false, true); } else { // Show folder contents - _view.ShowItems(target.Folder.Children, _sortType); + _view.ShowItems(target.Folder.Children, _sortType, false, true); } }