Trimming the Fat: Under 50MB

Hi there,
I just received a message from Apple claiming my binary, after processed by Apple exceeds 50MB. I know I have a few ways which can probably trim it down, getting rid a few audio files not in use, but are there other ways? And of that, I have a few questions.

  • Resources, everything in this is included in the binary?
  • Is it absolutely true that Unity only includes the Assets actually used in game, so, deleting a bunch of art that is just floating around, will that have any affect?
  • I have a folder that was created on my behalf, I think, Sprite Atlases. I am thinking all items in here, used or not are included in the binary. Is this true?
  • Yes! Everything in a resources folder, no matter where they are and how many there are is included.
  • No. Unity will only put assets in the build that are referenced in the scenes in the build (propagating through prefabs as well).
  • Only those that are used.

Other things to look at is to see what images you can change the import settings on. Also mesh compression can help. Also se if you can convert any of your sound effects to compressed (though realize that there could be a additional CPU load depending on the specific settings).

So basically, the Resources folder is my only target? Meaning, If I get rid of unused sprites in the Sprite Atlases folder, nothing will change in terms of memory?

Also, why would Apple processing boost the size of the app? I believe the email suggested the binary was 47MB but after Apple something or other, it is now 58.

??

A lot of my images are doubled up. Meaning I have one atlas xb for iPod (iPhone) and one that is usually doubled in size for iPad. This is to save memory on the iPod. How crucial do you think this step is? On average I save about half the memory, for the iPod. However, deleting would certainly bring me down under 50 MB. I am just wondering about performance on the non iPad devices. Of course this is for a universal build.

ALL files included in a Resources folder, or any subfolder of a Resources folder will be included in the final build of your application.

Nothing is loaded into RAM until you actively invoke Resources.Load() on the assets in the Resources folder. Sensible use of Resources.Load And Resources.Unload is paramount in keeping used RAM in check.

Compress all the textures you can without compromising too much quality, you need to strike a balance between quality and compression, and compress all the audio you can too. This will (usually) dramatically reduce file size if you haven’t already applied it. By the looks of the art style portrayed on your Brains Vs Dummies website, using 16-bit compression will be very easy, and PVRTC texture compression can be used when needed.

Use Unity Pro code stripping if possible as well, this will help a lot. If you don’t have Unity Pro, I’d HIGHLY recommend buying it. While expensive, it’ll be worth it in the long run.

The biggest user of file size if your assets. Compress them, take out stuff you don’t need and be sensible, and you’ll easily beat the 50mb limit.

Right,
I just removed about 10MB, but the file size is estimated at 52.4MB. Bummer. I will be fine, but I am going to have to spend extra time trimming.

Cheers.

What about Prefabs? Are all prefabs included or, again, only ones actually in the game somehow?

Also, despite cutting well over 12MB from my Unity project, Apple runs down the memory size at a different rate. Why is that? For instance, My file estimated size started at 58MB, I have got it down to 52, however I have cut more than a dozen MB from the Unity side of the project.

??

Also,
My build is Universal, my approach to this was to build two of every level. One for iPad, one for non iPad. I also, double each atlas. IPad atlases are double in size. I figure this contributes to any bloat. So, I removed all iPad levels from the build, however, this did virtually nothing in terms of Apples estimated size. Was quite shocked by that.

Bump.
Can anyone explain why a build, which virtually removed half of my textures, be the same size as with? *See second point above please.

After you build, click ‘Open Editor Log’ and you can find what assets are taking up the most space. Those figures won’t be 1:1 to the final .ipa size but their relative size is still valuable. It’ll also make it more clear what assets are included in your build, but I think based on import settings some won’t show up there properly (I remember certain audio files not being there but forget why).

Thanks.
Seems my fonts are choking up quite a bit. What is the best setting for them? I am currently using Character: Unicode, Font Rendering: Light Antialiasing.

I open my fonts in FontForge (which is free) and remove every glyph I’m not using. This can make a big difference to the app size depending on what was there when you started.

Thank you.
I believe I tried it once but with little success. Will look into again. What does it do exactly, basically compresses a font onto an atlas that is readable by Unity? Am I still using TextMesh’s as normal? Basically, would you think if used, I will not have to alter anything in terms of fonts beyond the material?

FontForge is a font editor. Getting rid of the characters you don’t use reduces the size of the .ttf and you might end up with a smaller generated texture size, which is where you can get major gains (I’m still using Unity 3, I don’t know what the effect will be with the new Unity 4 text features).