Search Unity

Official Quick Search Preview

Discussion in 'Editor Workflows' started by benoitd_unity, Feb 26, 2019.

  1. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes you are right. We will put something in place for this.
     
  2. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes I have noticed that issue. I wonder if it has something to do with pressing ALT? Is your shortcut bound using ALT? We also added contextual search, so in example you could bind it to CTRL+F and if the focused is on the Project Browser, it will open Quick Search and only enable the asset search provider. Maybe binding CTRL+F will prevent the textfield from eating all inputs. I'll make a few test today around this and see if it could be improved.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    2018.3/4, so no rebinds for me.
     
  4. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes the second one can still be printed. I asked the scripting team and what happens is that by the time the exception gets thrown, a domain reload also occurs and cancel the current domain code execution therefore ignoring the try/catch statement to not print the error. That said, other than being annoying the exception should not cause anything else. I still have to find a better solution.

    Do you get it that often? How big is your project? On my side I didn't get it that often, unless I was spamming the Play/Stop button while the quick search window was docked.
     
  5. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ahh shoot :( We really need to find a better shortcut that doesn't require ALT (maybe at least for version 2018.3/4). Let me think about something and I'll get back to you.
     
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Semi-often. Once every two or three times I enter or exit play mode? Something like that.
    Project is mediumish (10gb assets folder), but we're probably an outlier in number of assemblies (101)

    Also got a warning that indexing was aborted "probably due to domain reload". Yes, yes it was. You don't need to warn us about that.

    How near zero is the chance of convincing the release management team to allow backporting shortcuts management to 2018.4?
     
  7. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok we'll remove the warning.
     
    Baste likes this.
  8. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I can ask around, but since 2018.4 is now LTS I wouldn't expect that to happen. The shortcut manager required a pretty big refactoring of some low level systems, so I doubt we would take the risk to backport it to 2018.4 at this stage.
     
  9. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Yeah, I assumed as much. It's just a downer that a lot of the packages you will be shipping will probably rely on it for setting up shortcuts, so we might end up with package authors avoiding LTS for that reason.
     
  10. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Version 1.2.1-preview published with some minor fixes.
     
  11. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    I just found out about this and installed it - this is really great! Great work @jonathans42 and @sebastienp_unity (hello btw - it's been a while! :)

    Cheers,
    Sam
     
    jonathans42 and User340 like this.
  12. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi Sam, great to hear from you! It's a new tool still looking for feedback. Do not hesitate to let us know what works and what doesn't. The SearchProvider API is available too if you have some good idea to create a new provider for one of your tool.

    Have a great day!
     
    samizzo likes this.
  13. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    384
    Guys, why did your remove asset type filter in 1.2.1?
    Now it`s a complete mess, if you always want to just search for prefabs, or scriptable objects, but hundreds of models, shaders and materials are showing you don`t care about, search becomes really unusable.
     
  14. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    Doesn't show up in Unity 2019.3.0a2
     
  15. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    You can specify the filter yourself. If you are using the new indexed search you can simplify add the keyword "prefab" or through the asset database API by adding "t:prefab". With the new indexed search you should be able to type just a few characters to filter out additional stuff. The issue with the previous filter list was that it was incomplete and causing searches to be incomplete in many cases. When you do your searches try this: "<something> <type extension>" you'll get what you are looking for quickly. Make sure to enable the indexed search in the Quick Search settings.
     
    SugoiDev likes this.
  16. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    It will in 2019.3.0a6 when released in the hub or you can always find it as a preview package in the Package Manager.
     
  17. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    384
    What is the fastest way to search scriptable objects only?
    Please keep in mind, many big projects have entire databases from scriptable objects (e.g. Crowfall MMO as an example) and searching for them should be fast, so typing "<asset name> scriptableobject" would be super slow and annoying
     
  18. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Usually you do not need to type the entire extension, but you are right if that all your scriptable object type ends with .asset it would be hard to filter them, but the previous list wasn't showing all scriptable object types anyway.

    That said, I hear your feedback and we'll see how we can improve that in the next version. Meanwhile, enable the asset indexed search and try different pattern, like MSF, to match things like MySuperFile, etc. I am sure you'll quickly get how to form your search query to get quickly to the file you are looking for.

    Thanks,
     
  19. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Would you like me to provide you a custom SearchProvider example (c# script) that only search for prefab or some other type that you could tweak for your specific need?

    You could simply drop that script in your project or in another package that depends on com.unity.quicksearch and tweak it. You'll see, it is pretty simple to make a search provider for specific needs.

    Let me know.
     
    Last edited: Jun 4, 2019
  20. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    As soon as v1.2.2 is released you'll be able to write your own asset type indexer like so: https://gist.github.com/jschmidt42/0aa91bbb39f52fb5ba74ce75911769c6
     
    Last edited: Jun 4, 2019
    SugoiDev likes this.
  21. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    384
    Last edited: Jun 4, 2019
  22. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    New version 1.2.2

    - Add more performance, productivity and fun!
    - Add fuzzy search to scene objects search provider.
    upload_2019-6-5_9-41-46.png
    - [API] Add Search.customDescriptionFormatter to allow a search provider to indicate that the item description was already done and should not be done generically (used by the scene object search provider fuzzy search).
    - [API] Add SearchProvider.isExplicitProvider to mark a provider as explicit. An explicit provider only list search result if the the search query start with its filter id. In example, # will get into the calculator search provider and # will only return static method APIs.
    - [API] Expose the SearchIndexer API to easily add new search provider with indexed data.
    - [UX] Add ... to long search item description and show the entire description as a tooltip.
    upload_2019-6-5_9-41-57.png
    - [UX] Add more tooltips to some controls to indicate more advance features.
    - [UX] Allow the user to change the default action to be executed for search item with multiple actions.
    upload_2019-6-5_9-42-11.png
    - [UX] Make the asset indexed search the default search for the asset search provider.
    - [UX] Make the Quick Search window default size larger.
    - [UX] Separate regular search providers from explicit search providers in the filter popup window.
    upload_2019-6-5_9-42-21.png
     

    Attached Files:

  23. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I'm impressed with how much the development of this tool has progressed.
    At first I thought it would never be as good as my own stuff, but I'm glad to have been proved wrong.

    Really appreciate the development and communication going on here and I hope to see more of Unity going this route.

    Thanks a lot!
     
    jonathans42 likes this.
  24. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    New version 1.2.3

    - Add a new help search provider to guide the user how to use other search providers (type ? to get a list of search help items).

    - [UX] Draw some nice up and down arrows to order the search provider priority.

    - [UX] Add a status bar to give some context to the user what is going on and what is filtered or not.

    - [UX] Add a Reset Priorities button in the Settings window to restore all default search provider priorities if messed up for whatever reason.

    - [FIX] Fix the ordering of search provider priorities in the Settings window.
    - [FIX] Fix the order of explicit providers in the filter popup window.
    - [FIX] Fix a rare exception when the SearchIndexer is trying to write to the temporary index DB.
    - [API] Add `SearchAction.closeWindowAfterExecution` to indicate if the window should be closed after executing an action. Now an action can append to the search text and show additional search items.
    - [API] Add `ISearchView` interface for `SearchContext.searchView` to give access to some functionalities of the Quick Search host window.

    If anyone of you have tried the Quick Search API to add new search provider or search actions, please let us know what worked, what is missing and what could be improved.

    Also we'll probably moved the source code to https://github.com/Unity-Technologies so everyone can contribute if they wish too.

    Thanks,
     
    Peter77 and SugoiDev like this.
  25. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    305
    I'm enjoying the Quicksearch feature, but I wish it could be a little more intelligent. I'm often using it to open up and edit some prefabs which share the same name with corresponding .fbx files, folders, etc. If I type the name and open the prefab for editing 3 times in a row, maybe the Quicksearch window should consistently put the prefab at the top of the list of results? Instead, the order it returns is seemingly random :(
     
  26. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, are you using the latest version 1.2.3? Usually the recently used items should show first for the same provider. Do you use the global shortcut to open the quick search or do you use the shortcut to open Quick Search only for assets, i.e. Alt+Shift+O? As of now, contextual search do not persist settings, such as recently used items. Only the global search persist preferences through multiple session.
     
  27. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    305
    i just updated to 1.2.3 today. I use Alt+' to open the search...
     
  28. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok then the item you've selected once should show first with that new version. Let me know if that is still not the case and we'll fix it.
     
  29. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Hey, could you make the Unity.QuickSearch.FuzzySearch public? I'm creating a provider and don't want to have to modify the package itself, just extend it.


    I also have 3 (other) feature requests:

    1. A GUID provider. I use this often when I don't know what Unity is talking about in a diff or merge. It's useful and we can add it as a general provider safely, since we only have to actually hit it when the input is 32 chars long (then we just feed it to AssetDatabase.GUIDToAssetPath and see what it gives us).

    Example
    upload_2019-6-12_12-41-49.png


    2. When the GameObject's name is displayed in the search, it would be useful to include the scene name as well.
    I made a gist with the utility I use to format my GameObject's (and components) hierarchy path.
    https://gist.github.com/SugoiDev/33f21b96b34f85edaf8e2d0ea88bc179
    Feel free to use and modify it in any way.

    This is particularly useful when working on heavy multi-scene setups. For example, we have a bunch of objects named "Mechanics". But we want one on a specific scene to be selected. Without the scene name, we have to test each one.

    Here's a comparison
    screenshot 2019.06.12-12.38.46.png

    screenshot 2019.06.12-12.38.33.png


    3. In the scene hierarchy search box, I can use the t:SomeComponent to search for all GameObjects that have the SomeComponent component. On my own QuickSearch-like tool, I also added this and it's very useful. This is actually the provider I'm thinking of adding here.

    I'm rethinking it a bit because I read the SceneObjectsProvider source and I would have to duplicate a lot of what it does.
    It would help if I could access SceneObectsProvider.gods (I think this stands for GameObject Description?), so that I wouldn't have to create another array with the GameObjects (and wouldn't have to parse their names again). But that might introduce ordering issues.

    What do you think? If we're creating a provider for scene gameObjects, should we duplicate what SceneObjectsProvider does? Or add another layer of abstraction to providers so we can get some info from this abstraction that we can use on other providers?

    For example, most providers that want to deal with scene GameObject will end up doing
    UnityEngine.Object.FindObjectsOfType(typeof(GameObject)).



    Here's an example of my component search

    Normal search (no matches)
    screenshot 2019.06.12-11.48.49.png

    Component search
    screenshot 2019.06.12-11.48.40.png


    This is fairly heavy to have partial matching, since we need to build an index with all components and their names. So, it's probably best to have only direct querying. Like, t:ghosty should match t:Ghosty, like the scene search does. But t:ghost should not. This avoids us to have to build a possibly large index by finding all components.
     
    TextusGames and jonathans42 like this.
  30. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    All great ideas!

    We'll make the fuzzy search public, we'll add a guid provider (super great idea), we'll add the sub-scene name in the scene object search item description and for #3 we'll have too see, but we'll try something.

    Thanks,
     
    SugoiDev likes this.
  31. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    There you go for the GUID search (simple copy/paste a GUID in the search box).
    We added a sub-filter (e.g. guid) so you can disable it if someone thinks it slow down the search.

    upload_2019-6-12_13-3-16.png

    upload_2019-6-12_13-3-40.png
     
    SugoiDev likes this.
  32. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    SugoiDev what do you think of this formatting?
    Label: <transform path> (instance ID)
    Description: <sub scene name/prefab path>/<transform path> (fuzzy score)

    upload_2019-6-12_13-50-29.png

    I also added a new action to open the corresponding container asset. It will select/focus the asset in the project browser.

    upload_2019-6-12_14-11-56.png
     
    Last edited: Jun 12, 2019
    SugoiDev likes this.
  33. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I added prefab game object instance preview as well:

    upload_2019-6-12_15-11-12.png
     
    SugoiDev likes this.
  34. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Oh yeah, that looks awesome!
    I'll test it as soon as it lands.

    Thanks for such crazy fast response (and action).
     
  35. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I have a bit different case that Option(Alt) + Shift + O would stop working after a certain event, and from that point on it requires 1 click on any docked window to allow you to press the shortcut once. The only way to fix is restarting editor then it works fine until a "certain event" occur. I have a repro that Alt doesn't work which I think related to this problem, but it was flagged as low priority defect and Won't Fix. https://fogbugz.unity3d.com/default.asp?1157429_3t3sf1kt96j23b12
     
  36. TurboNuke

    TurboNuke

    Joined:
    Dec 20, 2014
    Posts:
    69
    Great tool!
    How would I go about implementing a Provider to search for specific text within a field of a certain asset type? (all my game's text is stored in SOs) ?
    Thanks.
     
  37. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok interesting, I'll take a look into that.
     
  38. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    You can take a look at https://gist.github.com/jschmidt42/0aa91bbb39f52fb5ba74ce75911769c6

    The idea is too fetch from the asset database all interested assets and then query the info you want and store them in an index for fast search. Unfortunately querying the asset database needs to be done in the main thread. If you are up to it, you can hack the system and go poke directly in the associated meta file using the file system API and index what you need.
     
    TurboNuke likes this.
  39. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi Aaron, I was able to repro your issue and a fix will be available in version 1.2.4 today or tomorrow.

    Thanks,
     
    Aaron-Meyers likes this.
  40. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi,

    Version 1.2.4-preview is now available. Special thanks to @SugoiDev for some great suggestions.

    - [UX] Add support to search asset by its GUID.
    - [UX] Add scene objects root container asset information.
    - [UX] Add prefab instance preview for scene objects
    - [FIX] Improve search provider filtering
    - [FIX] Fix recently used item persistence
    - [FIX] Add an active loop while installing and removing packages to prevent any race conditions.
     
    SugoiDev likes this.
  41. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Just noticed the Utils.GetEditorMainWindowPos is not very efficient.
    It adds about 1 second to the time it takes to show the QuickSearch window on my project.
    The reason being that it iterates over all types, which doesn't scale very well when we have many types.

    We can try using the UnityEditor.TypeCache, with 2019.2+


    Scanning the domain
    upload_2019-6-13_14-11-3.png

    Using the UntiyEditor.TypeCache
    upload_2019-6-13_14-18-12.png


    Feels much faster!


    I just replaced the start o the GetEditorMainWindowPos method

    Code (CSharp):
    1. internal static Rect GetEditorMainWindowPos()
    2. {
    3.     var containerWinType = UnityEditor.TypeCache.GetTypesDerivedFrom<ScriptableObject>().FirstOrDefault(t => t.Name == "ContainerWindow");
    4. ...
    but you can probably integrate it in the GetAllDerivedTypes method for better reuse.

    You can also look at using UnityEditor.TypeCache.GetMethodsWithAttribute with your GetAllMethodsWithAttribute method.
     
    jonathans42 likes this.
  42. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Wow ok! Integrating that in the next release for sure!

    Thanks,
     
    SugoiDev likes this.
  43. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I am also thinking of adding a public API directly in Unity Editor for GetEditorMainWindowPos instead of using reflection like we are doing now. it would be much faster in call cases.
     
    SugoiDev likes this.
  44. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I'm sometimes getting an exception:

    [Exception] ThreadAbortException
    Rethrow as InvalidOperationException: Failed to compare two elements in the array.

    Not sure what is causing it (never got it when I had a debugger attached).

    I'm attaching 3 logs with stacktrace + source position of when it happened.
     

    Attached Files:

    • 3.txt
      File size:
      2.6 KB
      Views:
      649
    • 2.txt
      File size:
      2.2 KB
      Views:
      593
    • 1.txt
      File size:
      2.7 KB
      Views:
      642
  45. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Oh yeah, that would be much better!
    I tend to avoid reflection as much as possible, in particular anything that iterates over the assemblies.
    At first it costs nothing, but I got some strong kicks when I got a project with over 100k types (lots of generated stuff to simulate functional languages features).

    The TypeCache is one of my favorite features Unity added recently. I think a lot of editor stuff will be much faster in the next year after devs start using it.
     
  46. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok that's the ThreadAbortException message erorr that can be caused when a domain reload occurs. You can usually ignore that message, I am still figuring out a way to discard the message.
     
    Last edited: Jun 13, 2019
  47. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Regarding the new feature to display the scene/prefab paths, take this screenshot
    upload_2019-6-13_15-6-54.png

    Those are all prefabs, and the prefab path is being shown.
    But, in this search we're most likely interested in the prefab instances in the scenes.

    Those are not prefabs. The scene name in bold is cool
    upload_2019-6-13_15-8-49.png


    I thought for a while and could not come up with a uniform solution to show the prefab path.
    Maybe for scene objects, we should only show the full hierarchy path, not the actual asset path.

    Like this

    Label: MatchedObject
    Description: [SceneName]/GameObject Hierarchy path

    Then we can continue to use the "Open containing asset" to actually go to the prefab
    To make it clear to the user that it is a prefab, we could make use of the editor icon for prefabs (same from the hierarchy).

    Mockup example for the icon
    try-3.png



    Now, still regarding this. In my search tool, I also match for the scene name.
    So, search "stage00 props" would show all objects with name that match "props", but only on stage00.

    Our project has many small scenes that are loaded as part of a CompoundScene, so we often have a few dozen small-ish scenes loaded at any time.

    One concrete example: we have some mask enemies with names containing the word Mask
    But we also have pixel masks, like to cover the screen.

    It is useful to be able to quickly filter all mask enemies that are in the Stagexx_Enemies scene.
    So we type enem mask

    The search, matching the "Stage01_Enemies" Mask enemies
    screenshot 2019.06.13-15.38.31.png

    I can further filter this to get the objects with Animators component
    upload_2019-6-13_15-39-7.png


    Well, that got a bit long.


    Let me know if this is confusing or out-of-scope. I'm typing real quick because I'm leaving the office for today.

    Thanks for reading!
     
    TextusGames likes this.
  48. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Oh yeah! Maybe a try-catch there and discard the exception then it is ThreadAbortException?
     
  49. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Not out of scope at all. I'll give that a try and get back to you.
     
    SugoiDev likes this.
  50. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Here's what I have so far. You can filter by sub scene name, transform path and components (any component, but only the first one is displayed in the item label).

    upload_2019-6-13_21-16-4.png

    It is also great to search scene objects that match a given script component:

    upload_2019-6-13_21-25-8.png
     
    Last edited: Jun 14, 2019
    TextusGames and SugoiDev like this.