Search Unity

[RELEASED]Power Tools: Hierarchy Folders

Discussion in 'Assets and Asset Store' started by SisusCo, Nov 27, 2019.

  1. SisusCo


    Jan 29, 2019

    Did you know that organizing your hierarchy under empty GameObjects can have a considerable negative impact on the frame rate of your game?

    But on the other hand, not organizing your hierarchy can have a huge negative impact on your work efficiency, not to speak of just general quality of life.

    What is a Unity developer to do in this no-win situation?

    Well, this is where Hierarchy Folders comes in. With the help of Hierarchy Folders you can organize your hierarchy just how you like it, while still avoiding all the negative side effects you usually get when using empty GameObjects for the job.

    Finally you can have your cake and eat it too!

    Asset Store - Buy Hierarchy Folders
    Join Mailing List - Be in the know


    Improve frame rate of your game by up to 40% by using folders instead of empty GameObjects to organize your hierarchy.
    ☑ Folders are clearly distinguishable from other objects in the hierarchy and in the inspector.
    ☑ Folder transform locked to default state so that states of children are never affected in any way.
    ☑ On-the-fly play mode stripping ensures 100% consistency with final build when playtesting in the editor.
    ☑ Order of transforms remains consistent through the stripping process.
    ☑ Configurable folder naming rules (uppercase, prefix, suffix).
    Menu shortcuts enable a very fast workflow for organizing your hierarchy.
    Thoroughly configurable to fit the specific needs of your project.​

    Bonus: Custom GameObject Drawer

    The following extra features require Power Inspector, due to the higher level of customizability it enables.
    Add component button hidden to prevent adding components to folders that are stripped from builds.(*)
    ☑ GameObject icon substituted with hierarchy folder icon.
    Configurable info text to clearly explain what hierarchy folders are.
    Tag field hidden to discourage referencing hierarchy folders in code.

    (*)If you add a component to a hierarchy folder using the default inspector (or code), it immediately turns into a normal GameObject.
  2. BPR


    Jan 4, 2013
    Hi, came across your asset and find it interesting but could you elaborate your point why performance suffers from Gameobject hierarchies?
  3. SisusCo


    Jan 29, 2019
    Sure thing @BPR ! I'll try my best to explain why flattening the hierarchies in your scenes can give such a substantial boost to performance.

    Unity internally groups all the transforms in your scene hierarchies into structures called TransformHierarchies.

    Each root transform in the scene is placed into its own TransformHierarchy along with all the child transforms underneath it.

    When a single transform changes in any way, it marks itself, all of its children and the TransformHierarchy it belongs to as being dirty.

    When an internal system in Unity requests a list of changed transforms, Unity has to iterate over every transform stored inside each of the dirty TransformHierarchy structures to generate the list.

    Because of this, the flatter your hierarchy is, the fewer transforms Unity needs to examine every frame when looking for changes.

    Additionally Unity utilizes a multithreaded job system when it examines the TransformHierarchies for changes. This makes it possible to examine multiple TransformHierarchies in parallel.

    TransformHierarchies however are the most granular level that Unity it will use when splitting these checks into jobs. This means that if you have a lot of child transforms under a single root transform, Unity can still only utilize a single thread when examining the whole hierarchy for changes.

    So the flatter your hierarchy is, the more effectively Unity can utilize multi-threading when it is looking for changes to your transforms.

    If you are interested in learning more here are a couple of resources on the topic that I highly recommend:
  4. SisusCo


    Jan 29, 2019
    Update 1.0.1 is now available for Hierarchy Folders! Here are some of the notable changes:

    A new custom Editor Tool was added for quick and easy creation of new hierarchy folders.


    If you have more than one GameObject selected in the hierarchy, they will be automatically grouped under the newly created hierarchy folder.

    Also renaming will start automatically for the created folder, so you can just immediately start typing a name for it.

    Another new feature is the ability to double-click a hierarchy folder to select all children.

    In addition to the children being selected, this also makes sure that the double-clicked folder is unfolded, and all the child GameObjects inside the folder are folded. This makes for a convenient way to quickly assess the full contents of a folder.

    I think that this double-click behavior makes more sense for hierarchy folders than the default behaviour of displaying the target in the Scene view, given that hierarchy folders are conceptually positionless and unseeable.

    New main menu items were also added under Tools > Hierarchy that can help in converting your existing empty GameObject containers into hierarchy folders.


    You can either convert an entire scene automatically, or manually convert only the GameObjects that you want.

    Even the full scene conversion has complete undo support, so you can try it out safely and reverse all changes if you realize you want to convert some things manually after all.
  5. MostHated


    Nov 29, 2015
    I saw this when it came out and I have been looking for something like this. I was hoping at least someone would have left a review by now, lol. I might just have to go for it and give it a try as my scene is becoming quite crazy to work with, trying to manage multiple Timeline "Acts" within a single scene. It would be nice to be able to organize things without messing up any of the transform positions and relationships as everything is very precisely placed.

    My only reservation is I tried something fairly similar, at least at it's core, it wasn't very feature rich though, that I found on github. If I remember correctly, the flattening of the hierarchy each time I wanted to hit play felt like it was taking forever and really slowing down my iteration cycle.
  6. SisusCo


    Jan 29, 2019
    Hi there!

    Sorry about the lack of reviews. I may have failed to give Hierarchy Folders the marketing push that it has deserves, having spent most of my time on the software development side these past few months :rolleyes:

    If you could give me an idea about the size and structure of your scene hierarchies (maybe take a screenshot), I could run some benchmarks to give you an estimate about how long flattening something like it would take.

    Flattening the hierarchy when entering play mode is also completely optional, so you could have the hierarchy only be flattened when making a build, but keep the hierarchy folders in use for play mode. Performance would not be optimal in play mode, but if your computer can handle it it's a great option.
  7. MostHated


    Nov 29, 2015
    I went ahead and bought it already yesterday and changed over a few Objects that were standard GO's over to be the new folder objects, but since most of what I am doing is simply scrubbing through and hitting play mode from time to time and not actually making any builds, it may not benefit me as much as I originally thought it might.

    My current project is primarily a cinematic / Timeline oriented project. One thing I am wondering, not sure if / how it would work exactly, but I have been looking into the newly added USD (Universal Scene Description) format, recording from Timeline, and exporting out to USD.

    The way the USD recorder / export works is you give the recorder a root gameobject from the hierarchy and it records everything under that hierarchy and exports it to USD format (which I am wanting to then import into Houdini to add particle effects and such that can be aware of the environment and animations of characters).

    Most everything in my scene is split up. Within a single scene I have the main root of the hierarchy, then might have an Environment GO, Lighting, Cameras, and then a Master Timeline with multiple Timeline "Acts" as child objects, then parented under the Act are objects that might be specific to that act. Each of those Acts may use the root Environment geometry such as trees, rocks, structures, etc.

    I want to make use of USD exporting, but since my stuff is broken up and there is no "root" object for the scene, and even if there was, there would be way more in the recording / export than I would like for there to be. So what I am wondering is, is there a way to use this asset to, say, temporarily parent multiple things that were all originally scattered in different hierarchies to a single root object for a single play session without losing any of their original placement so that after the recording and export is completed, it all goes back to how it was as if nothing changed?

    For instance, I might want a specific floor structure because that is where a character is standing and it has non-flat geometry, the character, and a camera as seen selected here:

    It would be great if I could parent them all to a single root object so I can add that to the USD recorder and then hit play, it can record just those objects and then put them back, without changing how anything works or where it is in worldspace, if that makes sense?

    My apologies for the wall of text, the question as a lot shorter in my mind when I first thought of it, lol.
  8. SisusCo


    Jan 29, 2019
    There's currently no functionality to do something like that using Hierarchy Folders, but this should do it:

    Code (CSharp):
    1. using UnityEngine;
    3. #if UNITY_EDITOR
    4. using UnityEditor;
    5. #endif
    7. public class TemporaryParenter : MonoBehaviour
    8. {
    9.     public Transform temporaryParent;
    11.     [SerializeField, HideInInspector]
    12.     private Transform originalParent;
    14.     private void Reset()
    15.     {
    16.         originalParent = transform.parent;
    17.     }
    19.     #if UNITY_EDITOR
    20.     [ContextMenu("Move Under Temporary Parent")]
    21.     private void MoveUnderTemporaryParent()
    22.     {
    23.         Undo.SetTransformParent(transform, temporaryParent, "Move Under Temporary Parent");
    24.     }
    26.     [ContextMenu("Restore Original Parent")]
    27.     private void RestoreOriginalParent()
    28.     {
    29.         Undo.SetTransformParent(transform, originalParent, "Restore Original Parent");
    30.     }  
    32.     [MenuItem("Tools/Temporary Parenter/Move All Under Temporary Parent")]
    33.     private static void MoveAllUnderTemporaryParent()
    34.     {
    35.         var parenters = FindObjectsOfType<TemporaryParenter>();
    37.         foreach(var parenter in parenters)
    38.         {
    39.             parenter.MoveUnderTemporaryParent();
    40.         }
    41.     }
    43.     [MenuItem("Tools/Temporary Parenter/Restore Original Parent For All")]
    44.     private static void MoveAllUnderOriginalParent()
    45.     {
    46.         var parenters = FindObjectsOfType<TemporaryParenter>();
    47.         foreach(var parenter in parenters)
    48.         {
    49.             parenter.RestoreOriginalParent();
    50.         }
    51.     }
    52.     #endif
    53. }
  9. MostHated


    Nov 29, 2015
    Awesome, I will give that a try. Much appreciated. : D

    One quick question I just thought of. If I place a folder down in the hierarchy at root, then say, place two more under that, then place an actual gameobject in those two which are parented under the first, are the transforms of the two gameobjects that I placed technically child objects using local space while editing even though the folder object shows no transform object?
  10. SisusCo


    Jan 29, 2019
    Yes, hierarchy folders do still actually have transform components under the hood and they act as the parents of objects grouped under them in edit mode. If hierarchy flattening is not enabled for play mode in the preferences, then this is also true in play mode. Under these circumstances there is no performance benefit to using hierarchy folders over empty GameObjects, as you would have to create a build before you would see the benefit.

    On the bright side you will still have all the convenience benefits of using hierarchy folders like:
    • Transform hidden and locked to default state.
    • Visual distinction between folders and other GameObjects.
    • Double-click to select children in hierarchy view.
    • Easy grouping of selected GameObjects under new folders.
    • Auto-naming functionality.

    There are also various extension methods for Transform and GameObject that can be used to do things like get the parent or the root, with the option to skip past hierarchy folders, in case someone runs into a situation where these would be useful.
    MostHated likes this.
  11. MostHated


    Nov 29, 2015
    I agree that the locked and hidden transform, as well as visual differentiation, are not bad to have. On a few occasions I have found that an organizational parent ended up being moved instead of the intended child object, I ended up having to go back and figure out what I goofed up and fix it, lol.
    SisusCo likes this.