• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by John3D · May 13, 2017 at 03:32 AM · android buildsizeapkeditor log

Why are the Levels (editor log) from build size so big 60.6% ?

Hi,

I hope somebody can help me solve this nasty problem. My APK build size is huge because of levels

 Textures      46.1 mb     24.0% 
 Meshes        7.2 mb     3.7% 
 Animations    17.1 kb     0.0% 
 Sounds        2.8 mb     1.5% 
 Shaders       1.3 mb     0.7% 
 Other Assets  8.6 mb     4.5% 
 **Levels        116.1 mb     60.6%** 
 Scripts       1.6 mb     0.9% 
 Included DLLs 6.4 mb     3.3% 
 File headers  1.5 mb     0.8% 
 Complete size 191.6 mb     100.0%

Has anyone had the same problem? I'm using Unity 5.5.2f1. Any advice is welcomed.

Thanks in advance for any answer!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by umairh_91 · Oct 13, 2017 at 06:31 AM

Disable static batching as it combines static (not moving) GameObjects into big Meshes, and renders them in a faster way, and reduce draw calls drastically but increased build size. go to player settings and disable static batching ...

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image joebain · Oct 31, 2018 at 12:09 PM 0
Share

This was exactly it for me, went from 900mb down to 120mb for a big open world forest scene.

avatar image
0

Answer by christiancrt · 3 days ago

This question is old, but the answer might be relevant for people that have the same problem as I find it to persist in 2020.3. It applies to games where you have scenes where you build your levels with prefabs.

First of all: @umairh_91 is completely right. Static batching does indeed bloat level sizes and if you want to keep your build size under 100mb, you will need to write a solution that batches at runtime, which is what I did with very acceptable results. Now since this has a mildly complex workaround (you can static batch at runtime via script), it is not as bad of an issue.

When I had this problem and fixed it, at thirst I thought that everything was fine. Later, I found that the problem persists. The levelsizes were still (and at the time of writing for me still are) much much bigger than you'd expect and in fact ruining the 100mb target completely on their own.

After digging and digging and digging I found that counterintuitively, prefabs are a PURE editor feature, meaning that all prefabs are unpacked completely during build. So if for example, you have a complex menu in every scene (pause menu for example), the whole thing is DUBLICATED in every single scene that has it. You'd expect that the scene only saves the reference to a shared asset that it then loads but no, it actually holds a copy of the whole thing. This finding is mentioned here: https://www.youtube.com/watch?v=4JLpJHIdx7E&t=3s Mind that a prefab that you reference that might have subprefabs is also unpacked at buildtime (I tested this). So, if you have many levels and make heavy use of prefabs and if your scene-sizes on disc compared to levels in build differs a lot, then this is probably the issue that you are running into.

The "solutions"/workarounds won't be perfekt and vary from case to case. The easiest thing would be if unity allowed for a different behavior of the player via a build option. But having in mind that this issue wasn't even adressed for 5 years while a complete rebuilding of the prefab functionality occured within that time, workarounds might be necessary... The workarounds 1 and 2 will make editing your scenes more difficult since you won't see a visual representation of your prefab anymore, but they work in a lossless way.

  1. Prefabs that have not been modified can be loaded at runtime. This forces the prefab to be referenced instead of dublicated (I tested this and can confirm a reduced build size if applied).

  2. If the prefab was modified in any way, you'll need a script that loads the unmodified prefab from disc and then applies the changes. Not exacly a low hanging fruit.

  3. For objects where you can't or don't want to apply workaround 2, you might want to remove all attached components and children that you can do without with or expand via a custom script, so effectively slimming the size of the prefab itself.

  4. Use scripts to expand/create your gameObjects and components at runtime where possible. Make use of the EditorOnly tag where applicable and delete all garbage from your scenes where possible.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

104 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Apk build has double size when building with Unity 2021.1.18f1 and build is not installable 0 Answers

Models still showing in editor log even after deleting them 0 Answers

Very weird results after building for android 0 Answers

Can build APK but it can't work and black screen when plays 0 Answers

64-bit apk size is extremely large. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges