The Search Window can be invoked from multiple places in the Editor. It is becoming more and more integrated to allow all sorts of workflows:
Main menu bar
Right in the main menu bar there is the official button to open the Global Search Window. This Search Window can also be invoked with the Ctrl + K
shortcut.
Each time you invoke the Global Search Window it is completely restored from its last invocation. Its size, position, enabled Search Providers, Icon Size, Table View and search text are all restored. The focus is right in the Search Field allowing to start typing directly.
Menu Items
We have created a lot of menu items to allow you to invoke the Search Window in various contexts.
- Find Files: Find any files on disk using our threaded Find provider supporting regex and globs.
- Scene: Open any scene in your project. This menu got convered in more details here.
- Asset Store: We have a SearchProvider allowing you to search the Asset Store itself! From this window you can either open the corresponding Asset Store web page or if you already bought the asset, you can open its page in the Package Manager.
- Asset Database: Search using the ADB provider.
Shortcut bindings
All of the menu items above and much more Search invocation can be bound to shortcut. Personnally I feel the more Search shortcut (Ctrl + K
) is part of your muscle memory, the easier it is to discover new Search usages. The Unity Shortcut Manager allows to bind all those Search invocation to your key sequence of choice:
Creating your own Search Invocation
If you create your own SearchProvider and you would like to setup a MenuItem or Shortcut to open the Search Window it is really easy.
Let's say you liked the Asset Store example above but you would like to only search for free assets on Christmas. Here is a snippet for you:
[MenuItem("Search/Free Asset Gifts")]
static void SearchStore()
{
var storeContext = SearchService.CreateContext("store", "price=0");
var viewState = new SearchViewState(storeContext,
UnityEngine.Search.SearchViewFlags.DisableNoResultTips |
UnityEngine.Search.SearchViewFlags.GridView);
viewState.windowTitle = new GUIContent("Free Stuff for Christmas");
viewState.queryBuilderEnabled = true;
SearchService.ShowWindow(viewState);
}
There are shorter ways to invoke the Search Window like SearchService.ShowContextual and SearchService.ShowWindow but this snippet showcase how to setup a SearchViewState in order to have absolute control on the appearance of the Search Window.
Goto Search button
Have you noticed these 2 buttons in the Editor?
These buttons can take you from the Hierarchy or the Project Browser to the Search Window. But why would you want to use this workflow if you are ALREADY in the Project Browser doing some nice filtering?
- Because the Visual Query Builder allows you to build a more complex and precise query.
- Or because you would like to save this Query on disk as a live Collection called a SearchQueryAsset. This workflow was covered in more details here.
Finding references in 23.2/23.3
Warning: the feature I am about to show you are currently in Unity 23.2 and 23.3. I will see if we can backport those to 22.3 No promises though. Also, in order to use these features your project indexing settings will need to have the dependencies option toggled. This post gives more tips on how to setup indexation in your project.
If you right click on an asset or a GameObject you now have new options to start a Search for reference:
And just like that you can easily find references to any assets (or GameObjects).
Finding properties in 23.3
Similarly, if properties are indexed in your project you can open the Search Window to search for object with a specific property value. Right click on any properties of an asset and select Search for same property
:
Naturally the same is true for GameObject:
Again if you feel this Query is valuable for you press the diskett icon and save it to disk.
Conclusion
The Search Window is integrated in multiple places within Unity Editor UI. And it is also really simple to add your own invocation. But in the end the more you Ctrl+K
the more your search life will be easier.