Search Unity

Object pools and static objects

Discussion in 'General Graphics' started by citizen_12, Mar 1, 2018.

  1. citizen_12

    citizen_12

    Joined:
    Jun 21, 2013
    Posts:
    33
    It’s been a couple years since this was last discussed and I didn’t see an official unity answer...

    I dynamically generate my world by putting mesh objects in an object pool then activating them at various places as the player moved. So they don’t move while active, but they do get placed, activated, deactivated, and re-used elsewhere (infinite runner style)

    So, for draw optimization should they be marked static or no?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    It's new to me, that Unity allows to mark objects as static during run-time. As far as I know, "static flags" is available in the editor only and various optimization techniques are applied to static objects while Unity is creating a build/player, not during run-time.

    In terms of optimizations, I recommend to use the Profiler to measure both cases on the particular target hardware. This will definitely give you an answer what's faster.

    Learn how to diagnose common performance problems and optimize your projects:
    https://unity3d.com/de/learn/tutorials/topics/performance-optimization