Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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


    Nov 22, 2016
    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


    Apr 10, 2014
    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


    Oct 11, 2012
    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:

    Last edited: Mar 19, 2023
    SanyaBane and CodeSmile like this.
  4. SanyaBane


    Nov 22, 2016
    Thanks. Used your idea and created Editor script: