Search Unity

Question Unity t: Search but only for root object and its children

Discussion in 'Editor & General Support' started by MikeUpchat, Aug 12, 2022.

  1. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Hi All
    I use the Unity search feature with the t:componentname to find components in the scene but as the scene gets bigger it is showing every single component of the type in the search results. Is there a way to say search this gameobject and its children for the component type. I have read through the search syntax page at https://docs.unity3d.com/Packages/com.unity.quicksearch@2.1/manual/search-syntax.html but to me its as clear as mud how you combine the search terms or if it is even possible, there are hardly any examples. Is it possible?
     
  2. sebastiengrenier

    sebastiengrenier

    Unity Technologies

    Joined:
    Jun 11, 2019
    Posts:
    96
    Hi! Yes, you can combine search terms to create more complex queries. Sorry if the documentation for the QuickSearch package is not clear enough. We have a better version of the documentation for the built-in Search (https://docs.unity3d.com/Manual/search-overview.html). Even if you are still using the package version, the documentation should still apply for the most part.

    For your particular question, you might want to look at https://docs.unity3d.com/Manual/search-query-operators.html. It shows how to combine terms with "And", "Or", "Not", how to group things up, etc.

    For a quick overview, anytime you add a keyword or a filter, it acts as a "And" operator, which means that the results must match all the terms. For example:
    t:texture width>32 blue

    means give me results that are textures with a width greater that 32 and matches the word "blue".
    t:texture or t:script

    would give you all the textures and script. And you can combine all of those with groups:
    (t:texture width>32) or (t:prefab t:canvas)

    would yield all textures with a width greater that 32 and all prefabs that have a "Canvas" component.

    So, to get back to your question, you could combine
    t:component
    with
    path:/path/to/my/object
    to get the results only for "/path/to/my/object" and its children (since
    path:
    acts as a contains and not an equal, it will match anything that contains "/path/to/my/object", i.e. "/path/to/my/object/and/children"). For example, I'm looking for the objects under "UI" that have the component "Canvas".
    upload_2022-8-12_10-54-47.png
    Without "path:", I would get results from all game objects.
     

    Attached Files:

  3. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Thank you for the reply and help, I have now tried Quick Search and as far as I can tell it is completely broken and useless, case in point using the search string 'type:limbtarget path:/---Vehicles N' will give the results as expected and as shown in the image below
    Screenshot 2022-08-15 113806.jpg
    Which is great, but add one more letter so 'type:limbtarget path:/---Vehicles Ne' and you get no correct results at all.
    Screenshot 2022-08-15 113957.jpg
    So how is this in any way useable?
     
  4. sebastiengrenier

    sebastiengrenier

    Unity Technologies

    Joined:
    Jun 11, 2019
    Posts:
    96
    That is because
    t:limbtarget path:/---Vehicles Ne
    is different than
    t:limbtarget path:"/---Vehicles Ne"
    (notice the double quotes around "---Vehicles Ne"). When you do
    path:XXX YYY
    , YYY is considered as another keyword to match, and in the scene simple words are matched against the game object's names, not their paths. Whenever you want to match against a phrase or reserved keywords such as "and" and "or", you need to use double quotes. Anything inside the double quotes will be treated as a single literal string.