Hierarchy Folders

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

Features

:ballot_box_with_check: Improve frame rate of your game by up to 40% by using folders instead of empty GameObjects to organize your hierarchy.
:ballot_box_with_check: Folders are clearly distinguishable from other objects in the hierarchy and in the inspector.
:ballot_box_with_check: Folder transform locked to default state so that states of children are never affected in any way.
:ballot_box_with_check: On-the-fly play mode stripping ensures 100% consistency with final build when playtesting in the editor.
:ballot_box_with_check: Order of transforms remains consistent through the stripping process.
:ballot_box_with_check: Configurable folder naming rules (uppercase, prefix, suffix).
:ballot_box_with_check: Menu shortcuts enable a very fast workflow for organizing your hierarchy.
:ballot_box_with_check: 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.
:ballot_box_with_check: Add component button hidden to prevent adding components to folders that are stripped from builds.(*)
:ballot_box_with_check: GameObject icon substituted with hierarchy folder icon.
:ballot_box_with_check: Configurable info text to clearly explain what hierarchy folders are.
:ballot_box_with_check: 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 Likes

Hi, came across your asset and find it interesting but could you elaborate your point why performance suffers from Gameobject hierarchies?

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 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:

3 Likes

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.

5262482--526433--creating-hierarchy-folders.gif

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.

5262482--526484--double-click-selects-children.gif
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.

5462349--558225--tools-hierarchy-menu-items.png

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.

1 Like

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.

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 :roll_eyes:

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.

1 Like

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.

1 Like

There’s currently no functionality to do something like that using Hierarchy Folders, but this should do it:

using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class TemporaryParenter : MonoBehaviour
{
    public Transform temporaryParent;
   
    [SerializeField, HideInInspector]
    private Transform originalParent;

    private void Reset()
    {
        originalParent = transform.parent;
    }

    #if UNITY_EDITOR
    [ContextMenu("Move Under Temporary Parent")]
    private void MoveUnderTemporaryParent()
    {
        Undo.SetTransformParent(transform, temporaryParent, "Move Under Temporary Parent");
    }

    [ContextMenu("Restore Original Parent")]
    private void RestoreOriginalParent()
    {
        Undo.SetTransformParent(transform, originalParent, "Restore Original Parent");
    }   
   
    [MenuItem("Tools/Temporary Parenter/Move All Under Temporary Parent")]
    private static void MoveAllUnderTemporaryParent()
    {
        var parenters = FindObjectsOfType<TemporaryParenter>();

        foreach(var parenter in parenters)
        {
            parenter.MoveUnderTemporaryParent();
        }
    }
   
    [MenuItem("Tools/Temporary Parenter/Restore Original Parent For All")]
    private static void MoveAllUnderOriginalParent()
    {
        var parenters = FindObjectsOfType<TemporaryParenter>();
        foreach(var parenter in parenters)
        {
            parenter.RestoreOriginalParent();
        }
    }
    #endif
}

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?

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.

1 Like

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.

1 Like

Hi @SisusCo

Thanks for Hierarchy Folders - I bought it yesterday.

My use case was simple. I’m basing my scene on a Synty 3D environment asset, which has a bunch (like a LOT) of assets all in the scene root. It was impossible to find anything.

Hierarchy Folders put it all right for me - was quickly able to group together like assets into folders and calm was restored in the universe.

Have a couple of feedback suggestions:

  1. I wanted to quickly select assets and then group them. Found no way directly in Hierarchy Folders, so bought another asset (Nparent AutoParenting) to group assets into a parent. I then used the Hierarchy Folder menu item to convert that parent gameobject. To cut this step, a Hierarchy Folder “Group Objects” menu would be nice. I’m sure it’s something I’ll need a lot.

  2. If you click on a folder (or gameobject) and select “Hierarchy Folder” from the context sensitive menu, it creates a sibling of the folder you selected. This is at odds with the rest of Unity. For example, if you select "3D Object"→Cube, it would create as a child of the folder. Could you change this (or make it an option) to keep it consistent with Unity?

I plan on using Hierarchy Folders in my future projects, and will certain convert my ongoing ones. It looks like a wonderful thing – I’m curious in particular to see how it reacts to mixing with RectTransforms for grouping UI elements.

Thanks again for putting it out there into the community. I’ll be sure to write you a review on the asset store when I’ve got more experience with it!

Hmm – looking at my point 1 above again, it looks like you actually have this feature via the menu toolbar folder button. Totally missed that - doh!

Maybe it would be good to add this to the menu tho - either the context menu or the Tools menu so people like me that don’t look hard enough find it first time?

Hi @Colin_MacLeod I’m glad that hierarchy folders has been useful to you!

Sorry to hear that you had a hard time figuring out how to quickly group multiple objects under a single folder parent. There are actually multiple ways to accomplish this. First you have to select multiple targets in the hierarchy and then you have to follow with one of the actions listed below:

1. Open the create menu by clicking the plus sign found on the hierarchy view toolbar and select the item Hierarchy Folder.
5462349--558216--create-hierarchy-folder-create-menu.png

2. Click the Editor Tools Toolbar icon.
5462349--558213--Enabling-Editor-Tool-Toolbar-Icon-3.png
To see the icon in the toolbar you first need to enable it by clicking the last icon found on your toolbar and selecting the item Hierarchy Folder.

3. Select the main menu item GameObject > Hierarchy Folder or use the shortcut Ctrl + Shift + G.
5462349--558222--create-hierarchy-folder-gameobject-menu.png

In addition to these methods that can be used to create new hierarchy folders it is also possible to convert existing GameObjects into hierarchy folders.

The simplest way to do this is to use the main menu item Tools > Hierarchy > Convert Selected to Hierarchy Folders.

5462349--558225--tools-hierarchy-menu-items.png

You can also automatically convert all GameObjects in the root of the open scene into Hierarchy Folders using the menu item Tools > Hierarchy > Convert Scene Root to Hierarchy Folders. This works well if you have a scene that is already using empty GameObjects for organizing all your scene objects.

All of these methods are also described in the documentation found at
Assets/Sisus/Hierarchy Folders/Documentation.

Do you think that adding a welcome screen that describes these methods or at least links to the documentation would be a good solution for improving their discoverability?

Thanks for the suggestion! I will make the context menu item create the hierarchy folders as a child of the clicked object. I’ll also add support for multiple selected targets for the context menu item while I’m at it, since that actually isn’t currently working properly either.

There is basic support for RectTransforms. They are currently just treated basically identically to normal transforms, with positions, rotations and scales kept locked at default values. Other values of RectTransforms (dimensions, anchors) are currently not locked or altered in any way, they are simply left as they were.

5462349--558246--RectTransform support.png
So if you convert a RectTransform that is at default state into a Hierarchy Folder it should work, but if it is using non-default anchor presets and such this could have an effect on the children.

If you have any suggestions on how RectTransform-based Hierarchy Folders could be improved further I’d be happy to hear them.

That would be very much appreciated, thank you :slight_smile:

1 Like

Cool - yes, I think that would really help impatient/unobservant people like me. I was specifically looking in in the context sensitive help for a “group into a folder” item.

I just submitted an update to Hierarchy Folders that contains the improvements for the context menu command discussed above, as well as introduces greatly improved support for RectTransforms.

Previously all Hierarchy Folders had a hidden Transform component and they were not aware about whether or not they had any RectTransform children or not.

Now if a new Hierarchy Folder is created under a RectTransform parent, or if a RectTransform child is moved under a Hierarchy Folder, then the Hierarchy Folder’s Transform component will automatically be converted into a RectTransform. It will also modify the anchorMin and anchorMax values so that the local state of any RectTransform children will no longer be affected at all by the hierarchy folder. This is all done without any children being affected of course.

Additionally anchorMin, anchorMax, pivot, offsetMin and offsetMax values will now also be kept locked for all RectTransform-based Hierarchy Folders. I’m not really sure how useful having this behaviour is given that the RectTransform is hidden in the inspector anyways, but it should be totally fool-proof now so users can’t inadvertently alter their states even through code or something :smile:

I’ll let you guys know once the update has passed the asset store approval process.

1 Like

The update is now available for download.

1 Like

@SisusCo Just left you a 5 star review for Hierarchy Folders and I bought Power Inspector for good measure too.

Thanks for all the great stuff!

@Colin_MacLeod Awesome, thanks a lot! It’s a great review to boot - I’m sure it will be most helpful to anyone on the fence about getting the asset.

I hope you’ll find Power Inspector very useful as well!

1 Like

How do you store the preferences? It appears to be local to each machine.
I pushed my project to version control and then when I pulled on another machine all the “—” lines appeared again. Personally, I’m not a fan of all the dashes - can these settings be made project specific?