I’m a bit shocked by the final size of my app for the iOS and Android. Both come in at about 200mb.
Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures 3.2 mb 1.4%
Meshes 0.0 kb 0.0%
Animations 0.0 kb 0.0%
Sounds 195.1 mb 87.0%
Shaders 8.7 mb 3.9%
Other Assets 1.4 mb 0.6%
Levels 70.5 kb 0.0%
Scripts 2.2 mb 1.0%
Included DLLs 13.3 mb 5.9%
File headers 162.3 kb 0.1%
Total User Assets 224.2 mb 100.0%
Complete build size 702.4 mb
Used Assets and files from the Resources folder, sorted by uncompressed size:
7.8 mb 1.1% Packages/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Uber.shader
2.4 mb 0.3% Assets/Music/Chillout/Chillout Bass7.ogg
My app is very music heavy and the data I import is around 32mb.
I found this in the documentation:
Unity re-codes imported Assets into its own internal formats, so the choice of source Asset type is not relevant. For example, if you have a multi-layer Photoshop Texture in the Project, it is flattened and compressed before building. Exporting the Texture as a .png file does not make any difference to build size, so you should stick to the format that is most convenient for you during development.
I’m wondering if this is also having an effect on my audio data? I really felt like my app is pretty slim. Could I be missing something? Do unused Assets also get added to the build?
Generally, unless you place assets inside a folder named ‘Resources’ or one of it’s sub-directories, they will be stripped from the final build if not referenced in any scene.
Consider looking at the compression options for your image and sound files in the inspector.
Thanks Sluggy, good to know that about the Resources folder. Will check.
I’m getting the impression that audio is not actually stored in the package the way I’ve added it. So my 300kb ogg audio files might end up being 2.2mb unless I set a lower quality in Unity. Would there be an advantage in writing my own audio-loader for the ogg files? I might also just be looking at the wrong issues here as the complete build size is supposedly 702 mb, with 480mb unaccounted for.
You can see what the compressed file size will be in the inspector after selecting your audio file. From there you can also adjust compression ratio/quality compression type and loading type as needed. Check out this page for more details. https://docs.unity3d.com/Manual/class-AudioClip.html. Image files similarly have such settings that should be adjusted as needed.
As well, you should review any global settings in your project settings. Things like code and shader stripping might be necessary to get your file size as minimal as possible. As a final step, assuming you are using a newer version of Unity, try removing any and all packages and Asset Store directories that you are not using. There is always going to be a certain amount of overhead regardless simply due to the engine itself and all of the DLLs it will will have to bring along in order to even run. But you might be able to reduce your size by getting rid of absolutely everythign not needed. I’ve personally never had a project mush smaller than 50-75 Mb but I’ve also never bothered much with compression and stripping.
I guess if all of that is still not enough you could try looking into Project Tiny. However, that is nowhere near production ready from what I saw last and hasn’t seemed to be developing at a particularly rapid pace compared to other aspects of Unity.
I found out that apk is nothing but a zip and so I unzipped it. Turns out there is a file called sharedassets0.resource that is exactly 195mb in size (100% the sounds). The apk is 229mb. So far I was using PCM, as I assumed the Compression Format was how Unity holds the asset when the game is loaded (reduced memory footprint). But it looks like it’s the way it’s stored. After switching all audio to Vorbis 50% the game size is down to 38mb and I can likely reduce it further.
I’m doing quite a lot of audio manipulation and was having some issues early on and I read somewhere I need to use PCM for things to work. This might be old info or even wrong, so I will see if I encounter any issues.
So my info was not entirely wrong. With Vorbis set to 50% I now have some cracking in my music. Not good. I’ve started a new thread over in Audio. I guess I need some way to bypass Unity handling the sound. Why is there no “Leave my bloody file alone” for compression format (at least when using ogg vorbis!!!)
The cracking was not Unity’s fault, but my music did not have nice loop borders. Strangely I never noticed before. I think adding compression just made it more audible, so it essentially helped me find a flaw 