1
\$\begingroup\$

I'm developing a game that should have 15-60 levels when all the environments of the levels are the same. I created a scene (level 1) and tried to build it; the total APK is around 38MB which is fine. But When I duplicated this scene to create the other levels and build my game the file size jumps to 148MB which is problematic for me.

Things I tried:

  • I optimized meshes, textures, and audio files.
  • I tried toggling static batching, SRP batching, GPU Instancing.

Here's some of the editor log of the second build:

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               6.2 mb    1.8% 
Meshes                 3.1 mb    0.9% 
Animations             781.3 kb  0.2% 
Sounds                 0.0 kb    0.0% 
Shaders                1.8 mb    0.5% 
Other Assets           652.6 kb  0.2% 
Levels                 323.1 mb  91.6% 
Scripts                3.6 mb    1.0% 
Included DLLs          13.4 mb   3.8% 
File headers           105.1 kb  0.0% 
Total User Assets      352.8 mb  100.0% 
Complete build size    678.6 mb
Used Assets and files from the Resources folder, sorted by uncompressed size:
 2.2 mb  0.3% Assets/Polygon/PolygonSamurai/Models/Characters.fbx
 1.2 mb  0.2% Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader
 1.0 mb  0.2% Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF.asset

I'm sure I'm doing something wrong but I don't know where the main problem is. Any help is so appreciated.

\$\endgroup\$
4
  • \$\begingroup\$ Have you tried making the shared environment a prefab? \$\endgroup\$ Commented Oct 14, 2021 at 14:25
  • 4
    \$\begingroup\$ Do you have "static" game objects in your scenes? These get turned into meshes and saved with the level geometry. Our golf courses in Pro Feel Golf were 2GB each because we had done that with the trees. Funnily enough, the docs on static objects say specifically "Do not use for trees!" \$\endgroup\$
    – Almo
    Commented Oct 14, 2021 at 14:31
  • \$\begingroup\$ @AcmeNerdGames I tried making the shared environment a prefab and the apk build became larger (Levels 355.4 Mb 92.3% ) \$\endgroup\$
    – WILO
    Commented Oct 15, 2021 at 9:16
  • \$\begingroup\$ @Almo I don't have any game object set as "static" in my scene \$\endgroup\$
    – WILO
    Commented Oct 15, 2021 at 9:17

1 Answer 1

2
\$\begingroup\$

I solved this by doing the following:

  • I placed everything in one scene
  • I created a prefab of every environment
  • I created a game object for each level, initially turned off
  • I created a script that loads a certain level and turns on/off the corresponding level objects and environment.

With this, my game composed of 15 levels dropped from 440Mb to only 45Mb.

Note: I used GPU instancing for the materials and turned off static batching for all elements, especially trees.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .