I’m using the Treeview API (https://forum.unity.com/threads/new-treeview-api.447169/) and have a search field hooked up, but when I clear the search field, the treeview scrolls back to the top and selected items aren’t visible. I basically want to mirror the functionality of the hierarchy search: if I do a search and select a row, then clear the search field, items above the selection should be expanded, and scrollview should be scrolled so the selected item is visible. Does anyone have a solution for this? I was surprised it wasn’t built in.
The FrameItem method DED-Games mentioned in their comment was just what I was looking for:
if(string.IsNullOrEmpty(eventTreeView.searchString) && ! string.IsNullOrEmpty(lastSearch))
{
var selection = eventTreeView.GetSelection();
if(selection != null && selection.Count > 0)
{
eventTreeView.FrameItem(selection[0]);
}
}