- Home /
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?
Hello thanks for getting back with me, I was wanting to create more thorough search filters for searching for scene items. The reason I was asking abou the class is that I thought there might be a member function in that class that gave the look of the search text field with the dropdown. I was creating a Unity Editor Extension called Super Search
If you want to get more information about the classes that comes with Unity, i recommend ILSpy. It's a C# / IL reflector. Just open the UnityEngine and UnityEditor dll and explore. $$anonymous$$eep in $$anonymous$$d that alot stuff is internal or mapped to native code, but it helps to understand how certain things are implemented.
If you found a internal / private function / property which would be useful, you could use reflection to use it, but i wouldn't recommend it. Internal stuff can change at any time and isn't ment to be used from outside. It can cause a crash or strange behaviour.
Just realized I commented on my own question...
Anyway, thanks for the info!
No, i've converted your answer to a comment since it wasn't an answer ;)
Anyway your super search looks good, however i don't need it, i have my own searching tool ;)
I agree with Bunny, ILSpy is a must. If you look in EditorStyles there's a lot of internal stuff that's worth reflecting and using including toolbarSearchField
, ToolbarSearchField
in EditorGUI and many more
Answer by EddyEpic · Jun 08, 2012 at 01:12 AM
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[i].name.Contains(searchString))
{
GUI.Label(items[i].name);
}
}
}
where "items" is an array of UnityEngine.Objects.
Answer by Bunny83 · Jun 08, 2012 at 03:13 AM
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?
Your answer
Follow this Question
Related Questions
Show public GameObject prefab in EditorWindow 1 Answer
Thumbnails from assets in an EditorWindow 0 Answers
How to get EditorWindow client rect? 1 Answer
Member arrays not initialized in editor until after scripts are recompiled 1 Answer
Any way to attach a bit of code to individual UI Windows [Editor] 1 Answer