Search Unity

Sprite Atlas for textures of material

Discussion in '2D' started by yanivng, Jan 22, 2019.

  1. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    Hi,

    I'm optimizing the memory consumption of my application.
    One of the optimization methods is creating a Sprite Atlas (Unity native) for several sprites, so that the atlas is both POT and square, and using texture compression on the sprite atlas (e.g. PVRTC for iOS / ETC2 for Android).

    I have done so for textures which are used for different materials (used in particle systems), but when using Unity's profiler, I see that both the SpriteAtlas and the individual texture are loaded in memory. It seems like memory consumption has grown larger. Any ideas what am I doing wrong here?

    Thanks,
    Yaniv
     
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    @yanivng In Editor, its possible that both the textures are loaded in memory.

    However in player, as long as
    1) Source textures are not directly referenced by any material or scripts
    2) Only supported renderers (SpriteRenderer, UI and SpriteParticles) are used.
    3) Sprites are packed to SpriteAtlas
    then the player should only load textures from Atlas for Sprite Assets.
     
  3. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    Hi Venkify,

    Thank you for your response.
    As the title says - I'm talking about textures referenced by materials. So from your answer I understand that those cannot be loaded from a sprite atlas?

    Thanks,
    Yaniv
     
  4. Hoorza

    Hoorza

    Joined:
    May 8, 2016
    Posts:
    45
    I would like to know that as well. From what I have gathered sprites in the atlas can't be used in materials. Can anyone confirm that?
    Cheerio!
     
  5. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    Yes, you cannot directly use a Sprite from Atlas in a Material.
     
  6. eradifyerao

    eradifyerao

    Joined:
    Feb 24, 2022
    Posts:
    2
    boogers.... That was gunna be my gleeming solution!