Reducing File Size
Manual     Reference     Scripting   
Unity Manual > Advanced > Reducing File Size

Reducing File Size

Unity post-processes all imported assets

Unity always post-processes imported files, thus storing a file as a multi-layered psd file instead of a jpg will make absolutely zero difference in the size of the player you will deploy. Save your files in the format you are working with (eg. .mb files, .psd files, .tiff files) to make your life easier.

Unity strips out unused assets

The amount of assets in your project folder does not influence the size of your built player. Unity is very smart about detecting which assets are used in your game and which are not. Unity follows all references to assets before building a game and generates a list of assets that need to be included in the game. Thus you can safely keep unused assets in your project folder.

Unity prints an overview of the used file size

After Unity has completed building a player, it prints an overview of what type of asset took up the most file size, and it prints which assets were included in the build.

Desktop

To see it just open the editor console log: Open Editor Log button in the Console window (Window -> Console).

iOS

To see it just open the console log: Help -> Open Editor console log menu.

Android

To see it just open the editor console log: Open Editor Log button in the Console window (Window -> Console).

An overview of what took up space

Optimizing texture size

Often textures take up most space in the build. The first to do is to use compressed texture formats (DXT(Desktop platforms) or PVRTC) where you can.

If that doesn't get the size down, try to reduce the size of the textures. The trick here is that you don't need to modfiy the actual source content. Simply select the texture in the Project view and set Max Texture Size in Import Settings. It is a good idea to zoom in on an object that uses the texture, then adjust the Max Texture Size until it starts looking worse in the Scene View.


Changing the Maximum Texture Size will not affect your texture asset, just its resolution in the game

How much memory does my texture take up?

Desktop

CompressionMemory consumption
RGB Compressed DXT10.5 bpp (bytes/pixel)
RGBA Compressed DXT51 bpp
RGB 16bit2 bpp
RGB 24bit3 bpp
Alpha 8bit1 bpp
RGBA 16bit2 bpp
RGBA 32bit4 bpp

iOS

CompressionMemory consumption
RGB Compressed PVRTC 2 bits0.25 bpp (bytes/pixel)
RGBA Compressed PVRTC 2 bits0.25 bpp
RGB Compressed PVRTC 4 bits0.5 bpp
RGBA Compressed PVRTC 4 bits0.5 bpp
RGB 16bit2 bpp
RGB 24bit3 bpp
Alpha 8bit1 bpp
RGBA 16bit2 bpp
RGBA 32bit4 bpp

Android

CompressionMemory consumption
RGB Compressed DXT10.5 bpp (bytes/pixel)
RGBA Compressed DXT51 bpp
RGB Compressed ETC10.5 bpp
RGB Compressed PVRTC 2 bits0.25 bpp (bytes/pixel)
RGBA Compressed PVRTC 2 bits0.25 bpp
RGB Compressed PVRTC 4 bits0.5 bpp
RGBA Compressed PVRTC 4 bits0.5 bpp
RGB 16bit2 bpp
RGB 24bit3 bpp
Alpha 8bit1 bpp
RGBA 16bit2 bpp
RGBA 32bit4 bpp

To figure out total texture size: width * height * bpp. Add 33% if you have Mipmaps.

By default Unity compresses all textures when importing. This can be turned off in the Preferences for faster workflow. But when building a game, all not-yet-compressed textures will be compressed.

Optimizing mesh and animation size

Meshes and imported Animation Clips can be compressed so they take up less space in your game file. Compression can be turned on in Mesh Import Settings.

Mesh and Animation compression uses quantization, which means it takes less space but the compression can introduce some inaccuracies. Experiment with what level of compression is still acceptable for your models.

Note that mesh compression only produces smaller data files, and does not use less memory at run time. Animation Keyframe reduction produces smaller data files and uses less memory at run time, and generally you should always use keyframe reduction.

Additionally, you can choose not to store normals and/or tangents in your Meshes, to save space both in the game builds and memory at run time. This can be set in Tangent Space Generation drop down in Mesh Import Settings. Rules of thumb:

Reducing included dlls in the Players

When building a player (Desktop, Android or iOS) it is important to not depend on System.dll or System.Xml.dll. Unity does not include System.dll or System.Xml.dll in the players installation. That means, if you want to use Xml or some Generic containers which live in System.dll then the required dlls will be included in the players. This usually adds 1mb to the download size, obviously this is not very good for the distribution of your players and you should really avoid it. If you need to parse some Xml files, you can use a smaller xml library like this one Mono.Xml.zip. While most Generic containers are contained in mscorlib, Stack<> and few others are in System.dll. So you really want to avoid those.


As you can see, Unity is including System.Xml.dll and System.dll, when building a player

Unity includes the following DLLs with the players distribution mscorlib.dll, Boo.Lang.dll, UnityScript.Lang.dll and UnityEngine.dll.

Page last updated: 2011-02-22