Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Use of Sprite Atlas causes major increase in build size

Discussion in 'Editor & General Support' started by dvdfu, Aug 25, 2023.

  1. dvdfu

    dvdfu

    Joined:
    Sep 1, 2015
    Posts:
    9
    Here's my situation:

    - Unity 2021.3 LTS, building for iOS (but Android is the same)
    - a lot of textures, almost all of them are packed into a Sprite Atlas
    - neither textures nor Sprite Atlases are stored in a Resource folder
    - when I include the Sprite Atlases, the editor log shows texture assets = 18.1Mb
    - I change nothing except disable Sprite Atlases from the build, texture assets = 4.8Mb
    - all Sprite Atlases are packed pretty well, there's very little empty space
    - most Sprite Atlases don't use compression (I am packing mostly pixel art)

    Maybe only 2 or 3 textures are directly references through materials, everywhere else I'm just including sprites through SpriteRenderer or UI Image components.

    I don't understand why there would be a >300% increase in texture size when DISABLING Sprite Atlases! I expect SpriteAtlases would have a small increase due to padding and inefficient packing, but this difference seems unrealistic.

    Image shows asset sizes in iOS build with Sprite Atlases (top) and without (bottom).

    Screenshot 2023-08-25 at 1.45.56 AM.png
     
  2. evyatron

    evyatron

    Joined:
    Jul 20, 2014
    Posts:
    132
    This might be an obvious one but worth checking - is your Compression (and ideally Crunch Compression) enabled for your Sprite Atlas object?
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,028
    What's the size (texture dimensions) of these atlases?

    Uncompressed RGBA 32-bit texture with 2048x2048 pixels amounts to 16 MB. Compressed or crunched it would likely still be a couple MB.

    You could check if you can do without alpha for tile sprites or reduce the color depth to 16 bit, which is often really hard to notice particularly on mobile and for players (yes, you'll notice a change in colors - but will the user?).
     
  4. dvdfu

    dvdfu

    Joined:
    Sep 1, 2015
    Posts:
    9
    I have 6 Sprite Atlases, 2 are using crunch compression, and 5/6 have Automatic format (the other is Alpha8).

    None of the base textures have compression enabled because I usually build my game through Sprite Atlases, which override the compression settings anyway.

    The main reason I was checking with/without Sprite Atlases is that I noticed a 400kB texture was packed into an atlas, but then later also included in the build at a 300kB size. 300kB seemed unreasonable for purely sprite data (mesh, import settings, etc.) so I tried building without atlases and was shocked to see the build size go down by many MB, where I expected it to increase due to lack of compression.

    Also @CodeSmile - thanks for the suggestion nearly every sprite I pack requires alpha, so I'm forced to use the RGBA32 format!
     
    Last edited: Aug 25, 2023