Search Unity

Make an Unity build light

Discussion in 'General Discussion' started by Orion_78, May 6, 2015.

  1. Orion_78

    Orion_78

    Joined:
    Feb 13, 2014
    Posts:
    66
    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

    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 http://fargesportfolio.com/make-an-unity-build-light/

    To know what is taking the most of your package space, and more information, check the Unity post here: https://docs.unity3d.com/Manual/ReducingFilesize.html

    Sample code to add a menu item that reimport all textures with a default settings
    Code (csharp):
    1.  
    2. using UnityEditor;
    3.  
    4. public class ImportSettings : MonoBehaviour {
    5.  
    6.     [MenuItem("Reimport/Reimport Textures with Defaults")]
    7.     static void ReimportTexture()
    8.     {
    9.         foreach(var p in AssetDatabase.GetAllAssetPaths())
    10.         {
    11.             TextureImporter i = AssetImporter.GetAtPath(p) as TextureImporter;
    12.  
    13.             if (i == null)
    14.                 continue;
    15.  
    16.             i.maxTextureSize = 64;
    17.             i.compressionQuality = (int)TextureCompressionQuality.Normal;
    18.             i.crunchedCompression = false;
    19.             i.npotScale = TextureImporterNPOTScale.ToSmaller;
    20.  
    21.             i.SaveAndReimport();
    22.  
    23.         }
    24.     }
    25. }
    26.  
     
    Last edited: Mar 19, 2018
    Mauri and sylon like this.
  2. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,219
    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.
     
  3. Orion_78

    Orion_78

    Joined:
    Feb 13, 2014
    Posts:
    66
    Hello everyone,

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

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,365
    Regarding this one, does Android support all of the various Zip compression methods?
     
unityunity