Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Feedback Building with gameobject

Discussion in 'Editor & General Support' started by a4g_, Apr 20, 2022.

  1. a4g_

    a4g_

    Joined:
    Mar 8, 2022
    Posts:
    45
    hello,
    I’m building a huge building let’s say an hospital, Instead of using the traditional level design method with polyshape which all the building including walls, floor and ceiling will be as one game-object in the hierarchy , I will use multi 3D game-objects (cubes) as walls and floor, so every wall in the building will be a separate game-object in the hierarchy, will this effect the performance of the game because of the huge amount of gameobject loaded in the hierarchy ?
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,672
    Yes, but it probably won't be enough to make any difference. Just build your level in the way that's easiest for you. If you start getting performance problems from too many objects, there are several mesh-combine tools on the asset store to clean it up.
     
    a4g_ likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,053
    Everything affects performance, but it may or may not make a difference, as @kdgalla notes above.

    Before you waste time trying to "pre-optimize" something you don't even have yet, keep this in mind:

    DO NOT OPTIMIZE "JUST BECAUSE..." If you don't have a problem, DO NOT OPTIMIZE!

    If you DO have a problem, there is only ONE way to find out. Always start by using the profiler:

    Window -> Analysis -> Profiler

    Failure to use the profiler first means you're just guessing, making a mess of your code for no good reason.

    Not only that but performance on platform A will likely be completely different than platform B. Test on the platform(s) that you care about, and test to the extent that it is worth your effort, and no more.

    https://forum.unity.com/threads/is-...ng-square-roots-in-2021.1111063/#post-7148770

    Remember that optimized code is ALWAYS harder to work with and more brittle, making subsequent feature development difficult or impossible, or incurring massive technical debt on future development.

    Notes on optimizing UnityEngine.UI setups:

    https://forum.unity.com/threads/how...form-data-into-an-array.1134520/#post-7289413

    At a minimum you want to clearly understand what performance issues you are having:

    - running too slowly?
    - loading too slowly?
    - using too much runtime memory?
    - final bundle too large?
    - too much network traffic?
    - something else?

    If you are unable to engage the profiler, then your next solution is gross guessing changes, such as "reimport all textures as 32x32 tiny textures" or "replace some complex 3D objects with cubes/capsules" to try and figure out what is bogging you down.

    Each experiment you do may give you intel about what is causing the performance issue that you identified. More importantly let you eliminate candidates for optimization. For instance if you swap out your biggest textures with 32x32 stamps and you STILL have a problem, you may be able to eliminate textures as an issue and move onto something else.

    This sort of speculative optimization assumes you're properly using source control so it takes one click to revert to the way your project was before if there is no improvement, while carefully making notes about what you have tried and more importantly what results it has had.
     
    a4g_ likes this.
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,932
    Note also that there are sometimes advantages to having many objects in the scene instead of few large, complicated ones. Mainly that Frustum Culling and Occlusion Culling can be used to dramatically reduce the amount of total geometry that Unity has to render.