Search Unity

Question Having a multiple selected gameobjects in "Hierarchy", how can I select their sub-gameobjects?

Discussion in 'Code Editors & IDEs' started by SanyaBane, Mar 18, 2023.

  1. SanyaBane

    SanyaBane

    Joined:
    Nov 22, 2016
    Posts:
    6
    Lets imagine I have a multiple gameobjects like this:



    For each of them I want to select some of their sub-gameobject - in order to edit some property on it.

    So I run through each gameobject in "Hierarchy" tab, expanding it, selecting sub-gameobject I need and repeat repeat repeat repeat....



    It's kinda ok if I have 5 gameobjects, but what if I need to change property of 100 sub-gameobjects like this? It's crazy.

    Is there a way so when I have 10 root-gameobjects selected, I could just "move" this selection to their sub-gameobject of my choice?

    How I see possible user-friendly solution: select all root-gameobjects I need in "Hierarchy" tab, then expand one of them, locate sub-gameobject I need, click on it (with some modifier like Shift/Alt or combination of it or maybe have a special icon of the left side) and thus "traverse" selection from all root-gameobjects to their sub-gameobject which I've clicked on.

    Obviously, it should work only if those gameobjects has same Tree-structure.

    P.S. changing a value in prefab is not what I want, because I would like to do this to:
    1. Non-prefabs
    2. Change values for only selected of prefabs in scene (e.g. 5 out of 10)

    So, is it possible to do something like this at the moment? If not, any workaround?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    You could write an editor script that works on the Selection class. For each entry in selection, you could do something like get the first child, put it in a list, and when you've iterated over the entire selection, make the list you created the new selection. Put that in a [MenuItem] static method so you can run it from the menu.
     
    SanyaBane likes this.
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    Use Unity's search. You can access the full version by clicking the icon to the right of the search on the hierarchy. From the search window you can browse the various filters with the tab key. It's not at all obvious but if you type a keyword, followed by a colon, and then hit tab you can see all the variations it allows. You can use multiple filters.

    Here's a cheat sheet of all of the filters available as of version 2.1:

    https://docs.unity3d.com/Packages/com.unity.quicksearch@2.1/manual/search-syntax.html

    upload_2023-3-19_15-34-32.png
     
    Last edited: Mar 19, 2023
    Lanyard31, SanyaBane and CodeSmile like this.
  4. SanyaBane

    SanyaBane

    Joined:
    Nov 22, 2016
    Posts:
    6
    Thanks. Used your idea and created Editor script:
    https://github.com/SanyaBane/Unity-Hierarchy-Multi-Selection-Children