SearchableEditorWindow

Does anyone know where I can find information on SearchableEditorWindow? This class exists in the UnityEditor namespace, but there is no documentation on it. I am wanting to implement a searchable window with a search bar at the top like the hierarchy view, and it looks like this class would be the right place to start.

If not, is there a way to add the hierarchy view type search bar to the gui?

You can add a search bar to the top by using:

string searchString = "";
void OnGUI()
{
   GUILayout.BeginHorizontal(EditorStyles.toolbar);
   GUILayout.FlexibleSpace();
   searchString = GUILayout.TextField(searchString, EditorStyles.toolbarTextField);
   GUILayout.EndHorizontal();

   // Do comparison here. For example
   for (int i = 0; i < items.Length; i++)
   {
      if (items*.name.Contains(searchString))*

{
GUI.Label(items*.name);*
}
}
}
where “items” is an array of UnityEngine.Objects.

Yes and no. Searchable means the window is searchable. This class has a private static list which hold all references to all created windows that are derived from this type. It’s actually meant as internal call as far as i can see. Most stuff is declared as internal and you have no way to actually search for an window since there is no public function for that.

Those windows are derived from SearchableEditorWindow:

  • SceneView
  • HierarchyWindow
  • ProjectWindow

The searchable has nothing to do with the hierarchy filter at the top (well there are internal function and fields, but only to hold the current used filter). It should be actually an internal class as well since it doesn’t make much sense to derive a class from SearchableEditorWindow.

So you would have to create your own search / filter - field like @EddyEpic said. What exactly do you want to search / filter?