I have a project unity game 2d. when i build it with 70 MB in apk, i think it too large with my game.
I try to delete some pictures (textures for backgrounds of game) about 6MB in my folder Assets\Resources (because my game load resource dynamically base on current level). Then rebuild it to apk. And it get 30MB. I wonder about it.
this is editor log when i build apk with 70MB
Textures 182.1 mb 95.7%
Meshes 0.0 kb 0.0%
Animations 0.0 kb 0.0%
Sounds 1.1 kb 0.0%
Shaders 42.5 kb 0.0%
Other Assets 594.9 kb 0.3%
Levels 485.3 kb 0.2%
Scripts 1.2 mb 0.6%
Included DLLs 5.1 mb 2.7%
File headers 791.0 kb 0.4%
Complete size 190.3 mb 100.0%
Used Assets, sorted by uncompressed size:
21.3 mb 11.2% Assets/Atlas/MainUIAtlas.png
16.0 mb 8.4% Assets/Atlas/SupportItems.png
12.0 mb 6.3% Assets/Resources/Backgrounds/A.jpg
12.0 mb 6.3% Assets/Resources/Backgrounds/B.jpg
12.0 mb 6.3% Assets/Resources/Backgrounds/C.jpg
12.0 mb 6.3% Assets/Resources/Backgrounds/D.jpg
9.0 mb 4.7% Assets/Resources/Map/bg_map3.jpg
9.0 mb 4.7% Assets/Resources/Map/bg_map2.jpg
9.0 mb 4.7% Assets/Resources/Map/bg_map1.jpg
9.0 mb 4.7% Assets/Resources/Map/bg_map4.jpg
8.0 mb 4.2% Assets/Resources/MainMenu/BG1.png
6.8 mb 3.5% Assets/Resources/MainMenu/BG2.png
.....
.....
I use NGUI for creating UI in Unity2d, so i have some atlas file. However, Assets/Atlas/MainUIAtlas.png is only 734KB when I see it in window. Why Unity compress it with 21.3MB?
And Assets/Resources/Backgrounds/A.jpg is only 194KB, but Unity compress it with 12MB...so on. All the information is too large to compare to real size in window.
I am new Unity, Please help me to explain and tell me how to resolve this issue. Thanks a lot.
Just because your resources file may be X mb in size, does not mean that the final build of those resources will be the same size. There's some hanky-panky that goes on when Unity3D compresses those resources. To try lowering your size you can try the following;
1) Use a lower quality compression setting. I used to just use ARGB32 but that's HUGE! You might want to try 16 bit instead. Depending on your resources you may not notice any quality reduction at all, but the size will be reduced.
2) Disable mip-maps. Mip-maps will increase the size of your resource by approximately 25%. If you have them enabled, but with no need you can save a lot of space here. A warning though, iOS used to contain a bug that meant even with mip-maps disabled iOS would still allocate the 25% space anyway. Not sure if that's been fixed.
3) Remove assets that are in your Atlas from your Resources folder. By default, Unity3D will shove everything in your Resources folder into your final build, even if you aren't using those assets. So try a spring clean and make sure there's only things in there that you need. If an image is in an Atlas, then it doesn't need to be included in the final build anymore.
4) Use more Atlas' that are smaller. If you keep adding to an atlas its size increases exponentially. 1024x1024, 2048x2048, 4096x4096 etc. The thing is, you may not be using all of that space and the Atlas has hundreds or maybe thousands of pixels of empty space. That data still has to be recorded and saved somewhere though. Make sure you're efficient with your Atlas'
5) Re-jig your images to suit your purpose. If you've got a huge background image that fills the entire screen - but at any given point you ALWAYS have a large portion of it covered by your game or other features then why not change the image to remove those unused areas? If an image is always drawn over at a certain point and you're still including that pixel information - then that's a waste. Doing this may result in 2-3 images that 'make up' the overall background, cutting out the middle or outer edge areas, for example.
6) Resize your image's dimensions. You seem to be targeting mobile. So are your resources applicable? There's no point having a 4k image for small screen sizes with lower resolutions. Maybe you can just reduce the image sizes overall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With