Make an Unity build light

Here is some tips to reduce your Unity build for any platform. Be smart, and adapted these advices to your project.
Graphics

Textures are what usually takes up the most space and performance. Take good care with your artist, like with your smart cats.
Any platform

  • Absolutely having textures under 2^n resolution. Otherwise, no compression and performance will be impacted

  • Set in Unity Inspector the adapted maximum size for each texture.

  • Be smart, If your texture is applied to a small surface, having a 56*56 is probably enough

  • Be careful when using Atlas. Unmanaged, they are often half empty and take lots of space and performance for nothing

  • Avoid Alpha, prefer the GrayScale option from Unity

  • Choose Sprite rather than textures (for performance)

  • Avoid sprite sheets or multiple similar sprite and replace them by code/animations. (keep one sprite button and add text animated “3”, “2”, “1”, “BOOM!”)

  • Disable the Generate Mipmaps if not used (UI, objects that are not moving far away from your screen, …)

  • Enable crunch compression. This will add lots of time to load your project afterward. Think of doing it just before you build or even in a build script

Android

  • Select ETC1 compression mode during the build

General

Any platform

  • Filter your Resources and Plugins directories. Unity will include everything from these folders when building, even unused assets

  • Enable compression on Meshes and Audio files. Be careful though, compressed mesh can greatly change the appearance of the model

  • Cut audio tracks (empty parts, loops,…)

  • More complicated, but nevertheless useful: use Proguard to strip the library and obfuscate the code at the same time (Use Proguard with Unity - Unity Engine - Unity Discussions)

Android

  • Limit the compilation within the Player Settings to ARMv7 architecture and drop the x86. Few Android Smartphone runs on x86 processors and it adds about +6MB to the project
  • Unpack and repack the APK with a good compression tool (like 7-zip ultra mode). Don’t forget to perform a zipalign after compression

iOS

  • Adjust the stripping maximum level (mscore lib) within the Player settings

Tools

More over my blog Unity Reducing size of your build – Farges Maelyss

To know what is taking the most of your package space, and more information, check the Unity post here: Unity - Manual: Reducing the file size of your build

Sample code to add a menu item that reimport all textures with a default settings

using UnityEditor;

public class ImportSettings : MonoBehaviour {

    [MenuItem("Reimport/Reimport Textures with Defaults")]
    static void ReimportTexture()
    {
        foreach(var p in AssetDatabase.GetAllAssetPaths())
        {
            TextureImporter i = AssetImporter.GetAtPath(p) as TextureImporter;

            if (i == null)
                continue;

            i.maxTextureSize = 64;
            i.compressionQuality = (int)TextureCompressionQuality.Normal;
            i.crunchedCompression = false;
            i.npotScale = TextureImporterNPOTScale.ToSmaller;

            i.SaveAndReimport();

        }
    }
}
2 Likes

For Windows build, you could use some software that make “portable” versions of program, then pack it even more using UPX or something like that. As an added bonus, this will also make game significantly harder to reverse engineer. Dunno about existence of such tools for Linux/Mac as I never felt the need to make portable version of something on Linux (and if I’d need one, I’d probably make my custom LiveCD distro) and I don’t have Mac. Both should have UPX tho as it’s open source.

Hello everyone,

I just make a quick fresh rewrite of the content to make it more readable. Hope you enjoy!

Regarding this one, does Android support all of the various Zip compression methods?

Good question that would need investigation :slight_smile:

This was a post from 2015. Please look at the dates of posts before replying i.e. don’t necro threads.

Thanks.