- Home /
Android Build Optimization for Unity - Textures
Hey there,
we are trying to reduce out build size for android. Currently out build size is 26.71MB.
Initially i thought may be its some issue with our textures/images. I created a new Unity project and built it, it's size was 18.4MB :(
Now, i know that unity have many different libs n all , thats why that size, and frankly we will have to leave with that. So, i proceeded to check the texture sizes. I took out editor.log and found this.
Launched and connected shader compiler UnityShaderCompiler.exe after 0.36 seconds
Compiled shader 'Standard' (total internal programs: 1176, unique: 532) in 11.07s
Compiled shader 'Hidden/Internal-PrePassLighting' (total internal programs: 468, unique: 116) in 4.92s
Compiled shader 'Hidden/Internal-DeferredShading' (total internal programs: 324, unique: 164) in 2.11s
Textures 45.7 mb 88.1%
Meshes 0.0 kb 0.0%
Animations 9.5 kb 0.0%
Sounds 980.1 kb 1.8%
Shaders 307.4 kb 0.6%
Other Assets 353.5 kb 0.7%
Levels 55.8 kb 0.1%
Scripts 538.5 kb 1.0%
Included DLLs 3.9 mb 7.6%
File headers 21.6 kb 0.0%
Complete size 51.8 mb 100.0%
Used Assets and files from the Resources folder, sorted by uncompressed size:
4.7 mb 9.0% Assets/Sprites/menu_background.png
3.5 mb 6.8% Assets/Sprites/pattern_1.png
3.5 mb 6.8% Assets/Sprites/ScreenShots/screenshot_3.png
3.5 mb 6.8% Assets/Sprites/ScreenShots/screenshot_2.png
3.5 mb 6.8% Assets/Sprites/ScreenShots/screenshot_1.png
3.5 mb 6.8% Assets/Splash Screen/splash_bg1.png
1.3 mb 2.5% Assets/Sprites/fireball/025.png
934.6 kb 1.8% Assets/Sounds/background.wav
682.8 kb 1.3% Assets/Sprites/Background_3.png
636.0 kb 1.2% Assets/Sprites/fireball/021.png
630.5 kb 1.2% Assets/Sprites/fireball/013.png
627.2 kb 1.2% Assets/Sprites/fireball/012.png
626.4 kb 1.2% Assets/Sprites/fireball/022.png.....any many more like this
So it looks like my file " 4.7 mb 9.0% Assets/Sprites/menu_background.png" above is 4.7MB, but the actual file size of that file is just 275KB, why unity is saying 4.7MB ?
Am i missing something ?
-Mahesh
Any one ?
For the question related to size i found out that you can build two different AP$$anonymous$$s for each architecture and give different version numbers to each of them and upload them to Playstore. This way you can achieve smaller size for your games :)
I have not yet found any answer to texture related question. Any one ?
Answer by OusedGames · Oct 19, 2016 at 01:53 AM
Go through each imported Texture and Sprite
At the bottom you can see the in-game size of your texture 0.8 mb
Uncheck "Generate Mip Maps
Set Format to "Compressed" - Decrease quality
And the bigger your texture the higher will be the size of it
Hope it works
Wow! It did work.
Though i am not totally sure why this is working, and why it is a good idea to untick "Generate $$anonymous$$ip $$anonymous$$aps" as there is a lack of documentation or may be this is a normal term for graphic guyz.
Generating $$anonymous$$ip $$anonymous$$aps will cause the texture file size to be larger. If you don't need mip maps, such as using sprite, then you can disable it to free up space.
Answer by Jessespike · Oct 18, 2016 at 06:10 PM
For Android compression (ETC1 and ETC2), textures need their width and height to be a power of 2. In the Texture Importer:
Set the "Texture Type" to Advanced and set "Non Power of 2" to Nearest.
Disable "Generate Mip Maps" if the textures are never viewed from a distance, such as GUI, splash backgrounds, etc.
Set the Format to "Automatic Compression".
Hey thanks for your answer. I should have mentioned that, It's a 2D game and i am using this images as sprites in the game.
That's fine. In the Advanced Type, there's a Sprite $$anonymous$$ode option.
Answer by Rockaso · May 12, 2018 at 06:57 PM
Hi, I set RGBA Crunched ETC2 and textures (PNGs 2D Texture atlasses made on photoshop) went from 4.0mb~ on final APK build to 100KB and they look good :D
Your answer
Follow this Question
Related Questions
does post processing stack work on android and simple depth of field doesnt show in mobile 1 Answer
Texturing - one big one or many small ones? 0 Answers
PNG on iOS? 3 Answers
Despite following Unity best practices, my iOS game bloat from 20MB to 60MB. Why? 1 Answer
Too much assets for mobile game 0 Answers