diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs
index bfded5380..3e5d22eb0 100644
--- a/Source/Editor/GUI/AssetPicker.cs
+++ b/Source/Editor/GUI/AssetPicker.cs
@@ -475,22 +475,31 @@ namespace FlaxEditor.GUI
if (_type != ScriptType.Null)
{
// Show asset picker popup
- AssetSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
+ var popup = AssetSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
{
SelectedItem = item;
RootWindow.Focus();
Focus();
});
+ if (_selected != null)
+ {
+ var selectedAssetName = Path.GetFileNameWithoutExtension(_selected.Path);
+ popup.ScrollToAndHighlightItemByName(selectedAssetName);
+ }
}
else
{
// Show content item picker popup
- ContentSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
+ var popup = ContentSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
{
SelectedItem = item;
RootWindow.Focus();
Focus();
});
+ if (_selectedItem != null)
+ {
+ popup.ScrollToAndHighlightItemByName(_selectedItem.ShortName);
+ }
}
}
else if (_selected != null || _selectedItem != null)
diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs
index ae470235d..42d236991 100644
--- a/Source/Editor/GUI/ItemsListContextMenu.cs
+++ b/Source/Editor/GUI/ItemsListContextMenu.cs
@@ -265,6 +265,35 @@ namespace FlaxEditor.GUI
_searchBox.Focus();
}
+ ///
+ /// Scrolls the scroll panel to a specific Item
+ ///
+ /// The item to scroll to.
+ public void ScrollViewTo(Item item)
+ {
+ _scrollPanel.ScrollViewTo(item, true);
+ }
+
+ ///
+ /// Scrolls to the item and focuses it by name.
+ ///
+ /// The item name.
+ public void ScrollToAndHighlightItemByName(string itemName)
+ {
+ foreach (var child in ItemsPanel.Children)
+ {
+ if (child is not ItemsListContextMenu.Item item)
+ continue;
+ if (string.Equals(item.Name, itemName, StringComparison.Ordinal))
+ {
+ // Highlight and scroll to item
+ item.Focus();
+ ScrollViewTo(item);
+ break;
+ }
+ }
+ }
+
///
/// Sorts the items list (by item name by default).
///