Search Unity

Creating sprite atlases at runtime

Discussion in 'UGUI & TextMesh Pro' started by jchowdown-asla, May 9, 2019.

  1. jchowdown-asla

    jchowdown-asla

    Joined:
    May 10, 2017
    Posts:
    26
    Hi Everyone,

    We're trying to figure out how to efficiently display 50-60 inventory icons at the same time, with as few draw calls as possible and taking up the least memory possible.

    Putting every one of our hundreds of sprites onto a small number of spritesheets will be fast to render, but take up a lot of memory. Loading and drawing everything as individual sprites will take many draw calls but will have the smallest memory footprint.

    We were wondering if we can dynamically create/manage a spritesheet that we can grow/shrink ourselves. Thus we could load and atlas whatever individual sprite we need at a particular time. If a spritesheet grows beyond a preset limit (say 1024x1024), we would create a new spritesheet to handle the overflow.

    Is there a way to do this in Unity 2017.4.25? I don't see any Google results for such a thing. (2018/2019 for that matter)

    Thanks!
     
  2. Wolar

    Wolar

    Joined:
    Sep 25, 2014
    Posts:
    38
    Hello @jchowdown-asla, did you in the end tried any solution like this? We are currently facing the same issue and I was thinking about building and maintaining sprite atlas at runtime. I'm just not quite sure it would be helpful in the end as it's basically trading some time on CPU to build the atlas with some time on GPU to render stuff and we are GPU bound on some devices but CPU bound on few other devices.