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
    Do you mind sharing the project you are using with 2018.4 (or any other project that repro the issue) that include quicksearch in the manifest.json?

    I've created a new project with 2018.4.4f1 and I didn't get that issue. Here's the zip of the project. Can you try to open it and see if you still get the same error?

    ExCSS.Unity is related to UIElements USS files so I wonder if you have another plugin/package that could mess up with the *.uss files.
     

    Attached Files:

    Last edited: Jul 25, 2019
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Thank you!

    My use case is currently this : I have a component which hold a string. I want this string to be quicksearchable instead of a path (with a new leading string like "qj:") and leads to the game object with this component. Also, it could do prefix/suffix so it works with 2018.3 new prefabs and overrides. For example, multiple instances from the same prefab has a problem with QS because name are the same. With prefix, I could modify only that and it would prefix all the label with what I want (which I linked in the prefab already, that could be the same) My game always have 2 instance of everything except that one is for the red team and one is for the blue team for example. This system would prefix "Red" and "Blue" label to everything. And I get only GO with the component, so only the important ones I jump to often.

    licecap.gif

    What I did is exactly like you said, I copied the whole scene provider code. There are some problems that static util classes are also need to be copied. And all required modifications needed for this :

    Code (CSharp):
    1.  
    2.                 var objectsWithLabel = objects.Select(x => x.GetComponent<QuickjumpLabel>()).Where(x => x != null && x.ExcludeFromSearch == false).ToArray();
    3.  
    4.                 //using (new DebugTimer($"Fetching Scene Objects Components"))
    5.                 {
    6.                     List<int> matches = new List<int>();
    7.                     var useFuzzySearch = objectsWithLabel.Length < k_LODDetail2 && context.categories.Any(c => c.name.id == "fuzzy" && c.isEnabled);
    8.  
    9.                     gods = new GOD[objectsWithLabel.Length];
    10.                     for (int i = 0; i < objectsWithLabel.Length; ++i)
    11.                     {
    12.                         gods[i].gameObject = objectsWithLabel[i].gameObject;
    13.                         var id = gods[i].gameObject.GetInstanceID();
    14.                         if (!componentsById.TryGetValue(id, out gods[i].name))
    15.                         {
    16.                             gods[i].name = objectsWithLabel[i].EvaluatedLabel;
    17.                             gods[i].rawname = objectsWithLabel[i].EvaluatedLabel;
    18.  
    19.                             // if (gods.Length > k_LODDetail2)
    20.                             //     gods[i].rawname = gods[i].gameObject.name;
    21.                             // else if (gods.Length > k_LODDetail1)
    22.                             //     gods[i].rawname = GetTransformPath(gods[i].gameObject.transform);
    23.                             // else
    24.                             //     gods[i].rawname = BuildComponents(gods[i].gameObject);
    25.                             // gods[i].name = CleanString(gods[i].rawname);
    26. ...
    First I have to replace both name and rawname because that seems to be what fuzzy search look at. I want my string to take place of the name, so I changed `null` on the `label` to `god.name` (which is modified to be my string) on the `provider.CreateItem`.

    Code (CSharp):
    1.             var item = provider.CreateItem(god.id, ~(int)score,
    2.                                            label: god.name, //changed
    3.                                            description: null, //kept
    4. ...
    Also while it works, it stopped highlighting in orange when anything not `null` is forced into `provider.CreateItem`. Not a big problem but would be nice if it still shows orange letters.

    This modification was done 2 times on the indexer's create item and the first create iterm.

    Lastly, the condition to rebuild was :

    Code (CSharp):
    1.             EditorApplication.hierarchyChanged += () => m_HierarchyChanged = true;
    2.  
    So this is not enough anymore, I have to also rebuild when any of my component was changed (in the case that it leads to searchable label change) or added/removed (need a rebuild to add remove entries). So I add OnValidate to my component with static bool as a bridge to the editor tools :

    Code (CSharp):
    1. #if UNITY_EDITOR
    2.         public static bool rebuildNeeded;
    3.         void OnValidate()
    4.         {
    5.             rebuildNeeded = true;
    6.         }
    7. #endif
    Then finally hack in an another criteria for rebuild :

    Code (CSharp):
    1.             onEnable = () =>
    2.             {
    3.                 if (m_HierarchyChanged || QuickjumpLabel.rebuildNeeded)
    4.                 {
    5.                     QuickjumpLabel.rebuildNeeded = false;
    6.                     componentsById.Clear();
    7.                     indexer = null;
    8.                     ...
    So what I want to say is filtering is certainly useful :

    • Perhaps some ways to tell scene provider to rebuild again other than hierarchy change is also needed.
    • Sometimes it is not a filter (keep or not), but I also want to change the entry's content that is showing / used for search. A good way in the long run that I believe, is to modularize the "collect all from open scenes or prefab stage" -> "index them on thread" logic that is currently baked inside scene provider, to something that is easily usable in 1 line in my own subclass. (So this class would appears mostly empty, but contains full scene search capability.) Became a static like the fuzzy search or string matching that is currently already open. Then this modular "fetch scene objects" method's output could be filtered or modified some item's name further based on custom logic before returning for the fetchItems delegate.

    ps. While I am building this plugin, I noticed that the asmdef is named "com.unity.quicksearch" , named like package.json convention instead of assembly convention. (e.g. "Unity.Quicksearch")
     
    Last edited: Jul 26, 2019
    SugoiDev likes this.
  3. TriNityKA

    TriNityKA

    Joined:
    Mar 19, 2019
    Posts:
    7
    Luckily fixing the issue was quite simple. During our upgrade to 2018.4 we had to recompile all our plugins and tools and a build script copied all dependencies into our Assets/Libs folder. For some reason, a few unity editor DLLs including ExCSS.Unity.dll. Once I deleted them, the compile error was gone :D

    Only thing that annoys now is the non-rebindable hotkey. ALT+' doesnt work on german keyboard layouts.
    Can you maybe add a bindable shortcut to the pre 2019.x Keys Manager?
     
  4. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok I have a better understanding of what you need. I'll sketch out something and get back to you for validation.

    Also, I'll fix the assembly name.

    Thanks,
     
  5. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yeah this one is really annoying for 2018.4 since we do not have the shortcut manager in that version. Maybe what we could do for 2018.4 is map two or three different shortcuts to the menu item. Let me see what we can do about it.
     
    TriNityKA likes this.
  6. TriNityKA

    TriNityKA

    Joined:
    Mar 19, 2019
    Posts:
    7
    Something like Shift+N is nice as its similar to Resharpers Instant Search shortcut :D

    Anyways, your package is amazing. Working with it is sooooo much faster than using the search bar of the project tab.
     
    jonathans42 likes this.
  7. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    So here's what I have so far (you can test the attached project if you want, a new version of QuickSearch is embedded).

    So lets say you have a script component like so:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class QuickLabel : MonoBehaviour
    5. {
    6.     [SerializeField] public string EvaluatedLabel;
    7.     [SerializeField] public string[] Keywords;
    8.     [SerializeField] public bool ExcludeFromSearch;
    9. }
    10.  
    EvaluatedLabel will be used as the item label and the array of keywords will also be used to augment the search matches.

    So now you can easily extend the scene search provider like so:

    Code (CSharp):
    1.  
    2. using System.Collections.Generic;
    3. using Unity.QuickSearch.Providers;
    4. using Unity.QuickSearch;
    5. using JetBrains.Annotations;
    6. using System.Linq;
    7. using System;
    8.  
    9. public class QuickLabelSceneProvider : SceneProvider
    10. {
    11.     const string k_ProviderId = "quick_label";
    12.  
    13.     public QuickLabelSceneProvider()
    14.         : base(k_ProviderId, "ql:", "Scene (Quick Labels)")
    15.     {
    16.         // (Optional) We do not want any subfilters for this variant.
    17.         subCategories.Clear();
    18.  
    19.         // (Optional) Update the functor that will fetch initial objects to build the game object descriptors.
    20.         // The array of game objects returned here will be the only objects used to build the index and used to search results.
    21.         fetchGameObjects = () =>
    22.         {
    23.             var objects = FetchGameObjects(); // Get original set of scene objects
    24.             return objects.Where(o => o.GetComponent<QuickLabel>() && !o.GetComponent<QuickLabel>().ExcludeFromSearch).ToArray();
    25.         };
    26.  
    27.         // (Optional) Update the functor that will build the list of words/tokens/keywords that will be used to match results and build the search index.
    28.         buildKeywordComponents = (descriptor, objects) =>
    29.         {
    30.             var basePath = GetHierarchyPath(descriptor.gameObject);
    31.             var quickLabelComponent = descriptor.gameObject.GetComponent<QuickLabel>();
    32.             return $"{basePath} {quickLabelComponent.EvaluatedLabel} {String.Join(" ", quickLabelComponent.Keywords)}";
    33.         };
    34.  
    35.         // (Optional) Update the functor that will return the label used for display
    36.         fetchLabel = (item, context) =>
    37.         {
    38.             var descriptor = gods[(int)item.data];
    39.             var quickLabelComponent = descriptor.gameObject.GetComponent<QuickLabel>();
    40.             return !String.IsNullOrEmpty(quickLabelComponent.EvaluatedLabel) ? quickLabelComponent.EvaluatedLabel : descriptor.gameObject.name;
    41.         };
    42.     }
    43.  
    44.     [UsedImplicitly, SearchItemProvider] static SearchProvider CreateProvider() { return new QuickLabelSceneProvider(); }
    45.     [UsedImplicitly, SearchActionsProvider] static IEnumerable<SearchAction> ActionHandlers() { return CreateActionHandlers(k_ProviderId); }
    46. }
    47.  
    So basically you create a new SearchProvider by extending SceneProvider and you only overrides the parts that you want to behave differently (i.e. fetchGameObjects, fetchLabel, etc.). Functors that aren't overridden will behave just like the builtin SceneProvider.

    So once the custom scene provider is compiled, you'll see this in the filter window:

    upload_2019-7-26_12-50-3.png

    If you do not want the built-in scene provider anymore, you can disable it in the preferences:

    upload_2019-7-26_12-50-41.png

    Finally, if you search with "ql:argon", this custom search provider will first only fetch game objects with the QuickLabel component and then match the objects that contains the component Keywords specified in the search query:

    upload_2019-7-26_12-51-51.png

    In your custom scene search provider you can set m_HierarchyChanged to true at any moment to have the index and game object descriptors rebuilt.

    I hope it covers the basic things you want in order to create custom scene search provider.

    We'll put something similar for those who would like to create new custom asset search provider as well.

    Thanks,
     

    Attached Files:

  8. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Hi, just wanted to say the fix for unloaded scenes worked perfectly! Quick Search is awesome and its development looks healthy, keep it up!

    I have a question concerning the post above:
    If you keep the SceneProvider enabled and extend it for a different provider, will the search logic be repeated and result in wasted processing power? I would imagine that the SceneProvider has to traverse all objects in the scene in order to perform its search, so would the traversal happen twice?
     
  9. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, you are right. The parsing and indexing of the scene will be repeated for each customization of the scene provider if we go with such an API. That said, it is the most flexible way to create a custom scene provider without having multiple scene filters conflicting with each others. I think the most important with this API is to have the functor fetchGameObjects returns a set of game objects as fast as possible so it doesn't block the UI, then the rest of the indexing and filtering is done asynchronously and should be responsive.

    Also that way, it is quick and easy to activate and de-activate a scene search provider. I'll continue to think about some other ways to allow custom scene providers. If you or someone else has a implementation to suggest please do and we will certainly consider it.

    Thanks,
     
  10. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Thank you! I didn't incorporate the new search modifier into my plugin yet, will provide feedback later. But I am back with one another search related problem.

    So currently it seems a lot of weight is given to recently activated items (searched and choose one of the context action?), but intuitively direct match should always win over them. Currently (1.3.2) it seems like the direct match loses.

    For example, there is a scene asset called GameSelectorArcade. I expected p:gameselectorarcade to show this at the top regardless of my search history. However, 3 other items won, and they are all that I just executed with Alt+R.

    licecap.gif
     
  11. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Try "game selector arcade" with spaces or "GSA". To be memory efficient with only index up 12 characters per word. So here "GameSelectorArcade.unity" generates these words: "game", "selector", "arcade", "gameselector", "gsa" "sa", "unity" and other variations... So if you use PascalCaseToNameFiles.something, then we generate words for those "pascal case to name files pascalcaseto something ...". So knowing how the index works, you can take advantage of this. So in your case above, many assets generated the word "gameselector" and stopped after 12 characters, so putting spaces in the search terms should fix it. We could add an options to index more than 12 characters, but then it would take much more memory, so I suggest that you take advantage of how words are generated for each entry/document and type these words separated by spaces. Typing many partially written words will also make the search work faster.

    So basically you can type in any order these words and you do not need to type them all. So if you are looking for GameSelectorArcade.unity, try this: "gam sel arc",or "unity gam sel arc" or even "uni ga se ar", etc.
     
    Last edited: Aug 5, 2019
    TextusGames and 5argon like this.
  12. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Today I noticed that the QuickSearch window remains blank and the following exception is logged to the console:

    NullReferenceException: Object reference not set to an instance of an object
    Unity.QuickSearch.Icons.LightenTexture (UnityEngine.Texture2D texture) (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/Icons.cs:70)
    Unity.QuickSearch.Icons..cctor () (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/Icons.cs:31)
    Rethrow as TypeInitializationException: The type initializer for 'Unity.QuickSearch.Icons' threw an exception.
    Unity.QuickSearch.Providers.DocScriptingHelper..cctor () (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/Providers/OnlineSearchProviders.cs:76)
    Rethrow as TypeInitializationException: The type initializer for 'Unity.QuickSearch.Providers.DocScriptingHelper' threw an exception.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    Unity.QuickSearch.SearchService+<>c.<FetchProviders>b__65_0 (System.Reflection.MethodInfo methodInfo) (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/SearchService.cs:478)
    UnityEngine.Debug:LogException(Exception)
    Unity.QuickSearch.<>c:<FetchProviders>b__65_0(MethodInfo) (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/SearchService.cs:492)
    System.Linq.Enumerable:ToList(IEnumerable`1)
    Unity.QuickSearch.SearchService:FetchProviders() (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/SearchService.cs:471)
    Unity.QuickSearch.SearchService:Refresh() (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/SearchService.cs:162)
    Unity.QuickSearch.SearchService:.cctor() (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/SearchService.cs:106)
    Unity.QuickSearch.Providers.AssetRefreshWatcher:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Library/PackageCache/com.unity.quicksearch@1.3.2-preview/Editor/Providers/AssetProvider.cs:283)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    I'm not sure how to reproduce this issue, it simply happened today after opening my project. I'm using version control and had been deleting folders and reverting the deletion in source control afterwards and then after re-opening Unity (and rebuilding the library) the issue occurred.

    After closing Unity and re-opening, Quick Search works again. I don't think I did anything weird or unsupported, maybe the package cache has issues unrelated to Quick Search itself.
     
  13. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Did you grabbed quicksearch from GitHub and without Git LFS? It looks like the icon image file are empty, or something like that? Which version of Unity and Quick Search are you using?
     
  14. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I'm using QuickSearch 1.3.2 installed via the package manager in Unity 2019.1.8f1. When the error was logged I checked and saw that the Texture2D in code was indeed null, but the icons were still present in the folder at the specified path, which is why I thought it might have been something wrong with the package cache since the error disappear after closing and reopening Unity once more.
     
  15. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok interesting, I am trying various scenarios to repro. Meanwhile, I'll add a guard in LightenTexture so it is more resilient. I'll let you know if I find anything else.

    Thanks,
     
  16. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    @jonathans42 I found a repro case:

    1. Disable "Auto Refresh" in the Unity General Preferences
    2. Create a new project and install Quick Search via the Package Manager
    3. Launch QuickSearch to confirm everything working without errors
    4. Delete the directory "Library/PackageCache/com.unity.quicksearch@1.3.2-preview" in the OS file explorer
    5. Press CTRL+R in the editor to refresh Unity
    6. Launch QuickSearch and notice warnings in the console about "null texture passed to GUI.DrawTexture"
    7. Quit and relaunch the Unity editor
    8. Launch QuickSearch and notice exception thrown in the console
    9. In the Project view under Packages/Quick Search/Editor/Icons notice the empty folder
    10. Press CTRL+R to refresh the editor
    11. Notice exceptions still being thrown when launching QuickSearch and take note of the icons folder now showing that the icons are in the correct place
    This should showcase the issue. However, I want to add, that I didn't delete my library when the error first appeared, but only reverted/changed assets via my version control system. I know this may sound a little obscure, but deleting the library should be supported in general; at least in the sense that I should be able to close Unity, delete the library, reopen it and all assets and packages are imported again correctly.
     
  17. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Ok I didn't know that was a common workflow. I'll test that and try to find a proper solution.

    Thanks
     
  18. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Hello, nice, now I know how things work I can consistently get it.

    I would like to ask about non-pascal cased case like "2P" for "two players", or UI / AI / GUI / ID / 2D / 3D, etc. that's a common abbreviation. I think currently it was not recognized as a word, so would be nice if it is able to in the future. For example, I cant get to this scene asset called "GameSelector2P.unity" at all.

    Screenshot 2019-08-15 13.40.47.png

    In VSCode, it is able to segment these kind of words. Though I don't know if it has a set of predefined exception words or some kind of algorithm is taking place.

    Screenshot 2019-08-15 13.43.36.png
     
    TextusGames likes this.
  19. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi,

    I was in vacation for the last three weeks. We will release v1.4.1 as a verified package first and then, I'll add support to Quick Search what you requested. It should be available in >=1.4.2.

    Thanks for the feedback.
     
    Last edited: Sep 4, 2019
    5argon likes this.
  20. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi 5argon, this will be available in version 1.4.2, here's a preview:

    upload_2019-9-4_16-29-48.png
     
  21. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hi! Loving this tool, It's allowed me to create a way nicer layout for working on the laptop!
    Just wondering, is it possible to rebind the shortcut on 18.4?
    Thanks!
     
  22. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi petey,

    Thanks for the feedback. Unfortunately 18.4 has no shortcut manager to remap the shortcuts. The best you can do with 18.4 is to create your own MenuItem function like so:

    Code (CSharp):
    1.  
    2. [UsedImplicitly, MenuItem("Help/Quick Search (Different shortcut) _&#o", priority = 9001)]
    3. private static void OpenQuickSearchCustomShortcut()
    4. {
    5.     QuickSearchTool.ShowWindow();
    6. }
    7.  
     
  23. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Thanks @jonathans42, I ran into some issues though.

    I'm getting this error for the Quicksearch tool -
    Code (CSharp):
    1. QuickSearchTool' is inaccessible due to its protection level (CS0122) [Assembly-CSharp]
    Also it doesn't like the UsedImplicitly part of the MenuItem -
    Code (CSharp):
    1. The type or namespace name 'UsedImplicitlyAttribute' could not be found (are you missing a using directive or an assembly reference?) (CS0246) [Assembly-CSharp-Editor]
    2. The type or namespace name 'UsedImplicitly' could not be found
    It's probably something simple but I couldn't figure it out :(
    Screen Shot 2019-09-10 at 9.02.52 am.png
     
  24. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi you do not need the UsedImplicitly attribute. Also make sure your script with MenuItem is under an Editor/ sub folder. Finally, make sure to update to the latest quick search version >= 1.4 to get all the new public APIs.

    You might want to specify the full namespace or use a using declaration, i.e.

    Unity.QuickSearch.QuickSearchTool.ShowWindow();
     
  25. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    Hmm that's weird, sorry to be a pain. Is there anything else that stands out as wrong here?

    Screen Shot 2019-09-10 at 2.00.04 pm.png

    Screen Shot 2019-09-10 at 1.41.10 pm.png

    Code (CSharp):
    1. using UnityEditor;
    2.  
    3. public class MenuItems
    4. {
    5.     [MenuItem("Help/Quick Search (Different shortcut) _&#o", priority = 9001)]
    6.     private static void OpenQuickSearchCustomShortcut()
    7.     {
    8.         Unity.QuickSearch.QuickSearchTool.ShowWindow();
    9.     }
    10. }
    Still getting this error :confused: - Assets/Editor/QuickSearchTweak.cs(8,27): error CS0122: 'QuickSearchTool' is inaccessible due to its protection level
     
  26. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Same problem for me with
    QuickSearchTool
    : the class is internal. Wanted to create a shortcut to quickly access the scene provider only.
     
  27. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Question: is it possible to not show a SearchAction if a certain condition fails? E.g. I would like to create SearchAction for a single type of asset. It seems we would need a new
    isShown
    handler to go along with
    isEnabled
    .
     
  28. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, yes that is something we want to do. It will require a bit of API change, but we'll do this for the upcoming version.

    We'll also make sure `QuickSearchTool` is public. I was sure it was already the case.

    Thanks,
     
    oxysofts and petey like this.
  29. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,824
    I was thinking, would it be possible to make the top search result selected automatically? So you could just type a few keys then press enter, rather than having to select the result manually.

    Also, is there a way for us to change the Quicksearch to public it in the meantime? Just checking, no stress if not.
     
  30. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    upload_2019-9-17_13-26-4.png

    upload_2019-9-17_13-29-2.png


    We've been using it for a little bit for our larger project, and i'm disabling it for now. Creating and moving assets has become incredibly slow, the editor feels way more sluggish.
     
  31. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    That's bad - the Quick Search should really not be doing stuff when it's not open!
     
  32. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Thanks for reporting. For sure this can be improved. Sorry for the trouble. I'll let you know when this gets fixed/improved.
     
    SugoiDev likes this.
  33. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes we'll make sure the next version has an API to spawn the UI through code.
     
  34. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yep you are right, we'll make sure late initialization like these do not happen until you've started to use quick search between two domain reload.
     
  35. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    These issues are now addressed with the new version 1.4.2-preview.2

    See https://docs.unity3d.com/Packages/com.unity.quicksearch@1.4/changelog/CHANGELOG.html

    Thanks,

     
    SugoiDev and petey like this.
  36. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I have a (hopefully) small feature request that might help newer users.
    This status bar
    screenshot 2019.09.23-16.02.13.png
    could have the shortcut to search with the provider.
    Like,
    Asset (p:), Menu (m:), Scene (h:), Settings (se:)


    New users will associate the shortcuts faster if they are frequently presented.


    Incidentally, I would like to reiterate something: In my opinion, this is one of the best packages in Unity right now.
    Hope to see more Unity stuff receiving the love this one is getting, both in actual development and forum communication. It has been pretty awesome.

    Thanks!
     
  37. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yes that is a good idea. Meanwhile, a user can type ? to get a list of choices or open the filter window and find the associated filter id to use. But I agree that adding them to the status bar is also a great idea. We'll try it out for the next version.
     
    SugoiDev likes this.
  38. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Thank you for the rapid iteration. It works exactly as the release notes say, its now only slow after you open the screen.

    https://www.dropbox.com/s/e75lfugqsiucx1k/rXmSRNtdAc.mp4?dl=0

    You can see the first time i create a folder i can immediately continue to use the editor, after i open and close the window there is a ~5 second delay. I was hoping that it would be possible to speed up this process, i still wouldnt recommend the package at this time.
     
    Last edited: Sep 25, 2019
  39. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    As you can tell from @TJHeuvel-net, that's not what we meant.

    This will vary from project to project, but I don't think most people will want to trade an increase in the performance of a specific tool (Quick Search) for a general degradation of performance.

    OnPostProcessAllAssets is dangerous to use, because you're showing yourself into every single part of the editor experience. That being said, it seems like QS is doing way too much as a reaction to that call. Somehow creating a single folder is causing it to allocate a list that's 2.8 MB large...
     
  40. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    I agree that depending on OnPostProcessAllAssets is not ideal, but it shouldn't take that much resources simply for creating a new folder. I have tried this in our biggest project A2 and I didn't get that lag and memory usage. Maybe there is something else that I haven't test or setup properly. Maybe that is something specific to 2019.2.

    I'll continue to investigate this issue and even try to dispose of the OnPostProcessAllAssets dependency if possible.

    Thanks,
     
    TJHeuvel-net likes this.
  41. esc_marcin

    esc_marcin

    Joined:
    Sep 30, 2016
    Posts:
    23
    Is it possible to search for all prefabs in assets which have a certain script?
    Something like
    p: t:prefab c:Camera
    to find all prefabs with a Camera component?
     
    Skjalg likes this.
  42. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    It is not possible to do exactly this type of search right now. That said, you can easily write a new search provider that could do this pretty easily or you can wait a little bit for the new upcoming QueryEngine that we are working on that will support a lot of additional filtering with many operators such as !,=,>=,<=,"...", etc.

    One problem with looking for a camera component within prefab assets is that without building an index, you need to load the prefab in order to get the list of components it contains which can consume a lot of resources. So that is why we are intending to build an index with this type of data so that the search is fast and doesn't consume a lot of memory in order to load objects into memory just to scan them.
     
    5argon, oxysofts and esc_marcin like this.
  43. sebastiengrenier

    sebastiengrenier

    Unity Technologies

    Joined:
    Jun 11, 2019
    Posts:
    96
    Hi everyone!

    Version 1.4.2-preview.3 has been released! It introduces some UX changes, bug fixes and a new provider, the Resource provider. Here is the complete changelog:
    • [UX] We've removed the dockable window mode of Quick Search since it wasn't playing nice with some loading and refreshing workflows and optimizations.
    • [UX] Add Resource provider, which lets you search all resources loaded by Unity.
    • [UX] Add documentation link to Help provider and version label.
    • [FIX] Add support for digits when splitting camel cases of file names.
    • [FIX] (1184860) Only enable the search asset watcher once the quick search tool is used the first time.
    • [API] Make Unity.QuickSearch.QuickSearch public to allow user to open quick search explicitly with specific context data.
    • [API] Add `QuickSearch.ShowWindow(float width, float height)` to allow opening Quick Search at any size.
    The Resource provider is a provider that can search all resources loaded by Unity, regardless of types, hide flags, etc.. This provider is explicit, and must be used by prefacing the search with "res:":


    With this provider comes four sub-filters to help constrain the search:
    1. Type, "t:", to search objects of a particular type
    2. Name, "n:", to search object of a particular name
    3. Id, "id:", to search for object with specific ids
    4. Tag, "tag:", to search for gameobjects with a specific tag
    Each sub-filter can be used to filter the list of objects on which the query will be processed, like mentioned above, but they can also be used for more specific searches. For example, if you want to restrain the search to tags only, you can type "res: tag: THETAG" (with a space between tag: and THETAG) and it will search for tags only. This can also be mixed: if for example you are looking for something with a negative id but you are not sure if it's a name for an object or a type of object, you can search with "res: id:- n: t: MYNAME"


    Thanks!
     
  44. dbillings_thehalseygroupllc

    dbillings_thehalseygroupllc

    Joined:
    Feb 15, 2016
    Posts:
    23
    Hello, I like the direction this is going!
    Quick question, is it possible to use this to search in adjacent project or specific file location?
    Example being I have another project or external file location that I reference in many other projects to grab bits and pieces from, can I use this system to input that project/folders location and pull up its assets when I search?
     
  45. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    By default it won't scan all your Unity project, that said, you could copy the AssetProvider.cs into your project (rename it, etc.), change a few things to point to your external project locations instead of the default Applicaiton.dataPath and it "should" work. Then you can edit the search item actions to copy or reference into your current these external assets.

    If you look at the following method in AssetProvider.cs:

    Code (CSharp):
    1.  
    2. [UsedImplicitly, SearchItemProvider]
    3. private  static SearchProvider CreateProjectAssetsProvider()
    4. {
    5.     var roots = new[] { new SearchIndexer.Root(Application.dataPath, "Assets") }.Concat(GetPackageRoots());
    6.     var fileIndexer = new FileSearchIndexer(k_ProjectAssetsType, roots);
    7.     fileIndexer.Build();
    8.  
    9.     var provider = CreateProvider(k_ProjectAssetsType, displayName, "p:", 25,
    10.         (context, items, _provider) => SearchAssets(context, items, _provider, fileIndexer));
    11.  
    12.     provider.subCategories.Add(new NameId("guid", "guid"));
    13.     provider.subCategories.Add(new NameId("packages", "packages"));
    14.  
    15.     AssetRefreshWatcher.Enable();
    16.  
    17.     return provider;
    18. }
    19.  
    Basically you'll need to tweak/edit this line to include your external project location:

    > var roots = new[] { new SearchIndexer.Root(Application.dataPath, "Assets") }.Concat(GetPackageRoots());
     
  46. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Would it be possible in the future to exclude c# scripts from the assets provider? We have a big project and it frequently clogs up Quick Search, and I prefer using my IDE to navigate between scripts if I need to.
     
  47. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, yes we want such a feature at some point. We'll let you know when that is available.

    Thanks,
     
    Last edited: Oct 15, 2019
    oxysofts likes this.
  48. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Is it possible to have Ctrl+N and Ctrl+P work as up/down arrows? This behavior is supported in other parts of Unity and it'd be really nice to have it work here as well.
     
  49. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Yep that is feasible. We'll add it to our TODO list and it should be available in an upcoming version.

    Thanks,
     
  50. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    This is great, I love being able to search the Packages folder quickly for filenames that I know exist but can't remember where they live. @jonathans42

    Quick question:
    Maybe I'm dumb, but what is the best approach to search all my scripts for code that exists in a .cs file, INCLUDING the Packages directory? I was hoping Quick Search could do this as well.

    Example: inside a file, Metadata.cs in one of my packages, I have a field "_versionMajor" - I want to search my entire project, including packages, for any code that matches "_versionMajor". Is this possible today?

    I could do some kind of explicit recursive folder search in an IDE... but Visual Studio afaik doesn't do this by default for the Packages folder. (why?) And on a similar note, "Go To Definition" does not work in Visual Studio for code in Packages- is there a way to load the content in Packages into the visual studio solution so that can work similarly?
     
    Last edited: Oct 24, 2019