Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Marking GameObjects static drastically increases APK size

Discussion in 'Android' started by Zocker1996, May 26, 2016.

  1. Zocker1996


    Jan 12, 2015
    So I'm building a 2d Platformer but with 3d objects (like super mario) for iOS and Android.
    I just created 19 Levels. A Level contains about 2000 GameObjects. About the half of them is just for structure (and could be removed if nessecary).
    All my meshes use the same material (same texture with Mobile Diffuse shader).

    My build apk is quite big: 20mb apk plus 160mb obb.
    I recognized that static batching is the cause:
    To reduce drawcalls I marked as much objects as possible static.
    I examined the Editor.log for a build with static batching:

    Textures 94.1 mb 11.0%
    Meshes 1.8 mb 0.2%
    Animations 347.1 kb 0.0%
    Sounds 9.9 mb 1.2%
    Shaders 119.9 kb 0.0%
    Other Assets 69.6 mb 8.1%
    Levels 672.3 mb 78.5%
    Scripts 810.8 kb 0.1%
    Included DLLs 3.9 mb 0.5%
    File headers 3.2 mb 0.4%
    Complete size 856.1 mb 100.0%

    After I unmarked the static object and building again the output akp was again 20mb big,
    but the obb was just 25mb big, so just abut 16% compared to the build with static batching:

    Textures 94.1 mb 56.0%
    Meshes 1.8 mb 1.1%
    Animations 347.1 kb 0.2%
    Sounds 9.9 mb 5.9%
    Shaders 119.9 kb 0.1%
    Other Assets 5.5 mb 3.3%
    Levels 48.4 mb 28.8%
    Scripts 810.8 kb 0.5%
    Included DLLs 3.9 mb 2.3%
    File headers 3.2 mb 1.9%
    Complete size 168.0 mb 100.0%

    Is this normal for static batching or am I just doing something stupid?
    If this is normal, shouldn't I just disable static batching?
  2. bluescrn


    Feb 25, 2013
    On a large mobile project the 'levels' size in our build appears to have shot up from 145MB to 546MB when we turned on batching (after discovering that everything had just been set to 'lightmap static' for the entire project, and trying to get some more performance out of it...)