- Home /
Grouping objects without overhead?
Sometimes it is preferable to group multiple objects (e.g. of the same type) in Hierarchy
into one group (so that 100 objects at the top of the Hierarchy
don't clutter it). I used to do that by creating an empty GameObject
and attaching the objects as its children.
But lately a colleague of mine discovered that even adding an empty object as a parent has significant performance overhead during gameplay. For why is that I have no idea but that's beyond this question's scope.
Is there any way of grouping objects without affecting game's performance?
I've read here: http://answers.unity3d.com/questions/118306/grouping-objects-in-the-hierarchy.html that setting the group-object's position to
(0, 0, 0)
should help, is it true? Is it treated by Unity differently then?
It is good to know the answer.
But I have many suspicious about your friend performance test. Remember, if is not a problem in your project, you don't need to solve :P
I wrote it does affect performance in my project. Significantly.
Answer by rutter · Jun 03, 2014 at 08:59 PM
There is some performance overhead associated with hierarchy grouping, but it's not very big unless you're re-parenting hundreds or thousands of GameObjects per frame.
The "empty" parents should generally be at location (0,0,0), with rotation (0,0,0), with scale (1,1,1), to avoid unintuitive positioning issues.
I'm curious what scenario you've seen where this became a significant performance problem. Do you have profiler or other benchmarking data to back that up? Is the issue reproducible?
Do you know for certain whether default (identity) transform is optimised anyhow in Unity (performance-wise)?