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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Sprites and Sprite Atlas both in (Android) build

Discussion in '2D' started by GJBooij, May 5, 2020.

  1. GJBooij

    GJBooij

    Joined:
    Jun 18, 2013
    Posts:
    10
    Hello,

    When I'm building my android apk and I include the Sprite Atlas in my build, it pakcs both the atlas and all the resources that are in it seperately. Can someone maybe explain to me how this works?
    As I found this in the documentation:

    Scenario 1: Basic Sprite Atlas usage
    1. Sprite Atlas A contains Sprite 1.
    2. Sprite Atlas A has Include in Build enabled.
    3. Result: The Project’s published build includes Sprite Atlas A. Sprite 1 renders with the Texture from Sprite Atlas A.
    Link: https://docs.unity3d.com/Manual/SpriteAtlasScenarios.html

    But when I do this, the result is different.
    I do get both the sprites and the sprite atlas in my build, and thus increasing size.


    Editor log:
    256.2 kb 0.3% Built-in Texture2D: sactx-512x512-ETC2-Blue-2bc0bf41
    ...
    3.6 kb 0.0% Assets/_UI Assets/Blue.spriteatlas
    ...
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_sliderLeft.png
    0.5 kb 0.0% Assets/_UI Assets/blue/green_panel.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_panel.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button09.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button07.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button06.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button05.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button03.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button01.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_boxCross.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button12.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button10.png
    0.5 kb 0.0% Assets/_UI Assets/blue/blue_button08.png
    (etc. list is way longer)

    So reading the docs, I wouldn't expect that last list of textures being inside the build?

    Thanks!
     
  2. piyush_unity_pba

    piyush_unity_pba

    Joined:
    Aug 11, 2021
    Posts:
    1
    If a sprite is part of Atlas, the source texture is never added to the build, only the sprite (which does not hold any texture data, just sprite and some geometry info). The only texture that is built for texture is the Atlas texture (sactx-128x128-ETC2-New Sprite Atlas-5788029a)

    Based on above post (https://forum.unity.com/threads/sprite-atlas-adding-on-build-size.608143/#post-4351309) , :
    0.7 kb 0.0% Assets/icon_dolar.png (Sprite) => This is not Texture but Sprite data (vertices, properties etc..)
    0.2 kb 0.0% Assets/New Sprite Atlas.spriteatlas (SpriteAtlas)
    16.1 kb 0.0% Built-in Texture2D: sactx-128x128-ETC2-New Sprite Atlas-5788029a (Texture2D) => Texture for the Sprite.

    Source texture is only included if its also referenced elsewhere other than SpriteRenderer (for example like Material etc..) or inside resource folder.

    The idea of Sprite-Atlas is to pack all source textures of sprites to a single texture and use it as a source for the sprites. So this is exactly as expected.
     
    Last edited: Apr 29, 2022