x


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?

more ▼

asked May 18 '12 at 06:39 PM

deus_duke gravatar image

deus_duke
18 4 6 8

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

Jun 08 '12 at 03:18 AM deus_duke

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. Keep in mind 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.

Jun 08 '12 at 03:29 AM Bunny83

Just realized I commented on my own question...

Anyway, thanks for the info!

Jun 08 '12 at 03:34 AM deus_duke

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 ;)

Jun 08 '12 at 03:36 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

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?

more ▼

answered Jun 08 '12 at 03:13 AM

Bunny83 gravatar image

Bunny83
46.9k 12 50 210

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 08 '12 at 01:12 AM

EddyEpic gravatar image

EddyEpic
30 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1730
x351
x175
x71
x7

asked: May 18 '12 at 06:39 PM

Seen: 749 times

Last Updated: Jun 08 '12 at 03:36 AM