Our artists provide individual images for each sprite. Basically one icon/graphic per (sprite)texture. These individual images are set to TextureType=Sprite in Unity’s Texture Importer and by using the Sprite Packing Tag, we can tell Unity that we would like to have these individual images be packed in an atlas. Depending on the number and size of each sprite, Unity might create multiple atlases.
Maybe you don’t really have to, see my idea below.
I thought so. While it would be neat to have support for that, it’s not very important for me personally.
References to individual sprites in the project stay intact after Unity created the atlas. It seems Unity magically patches/replaces such references during play or build.
Here is how I picture support for both workflows could be implemented:
A TextMesh Pro Sprite List entry would have a Sprite reference, where users can drag&drop a Sprite from the project. Implementing support to automatically add all sprites of an atlas (one texture that contains multiple sprites) to the list should be trivial, so it’s little effort for the user to add 1000 sprites to that list and is pretty close to with what you came up already.
The ID needs to be stable. Maybe implement functionality to make that number only increase per added list entry, but never let it decrease. Once a list entry has been added, it’s guaranteed that this ID stays the same no matter what. Plus the list entry also needs all your extra data OX, OY, Adv, etc. I would probably get rid of the “Sprite Atlas” field in your TextMesh Pro Sprite Asset too, because it’s not necessary anymore and does not work with the workflow we use. Since you have references to each individual sprite, you have a reference to the atlas(es) automatically too (sprite.texture).
When the TextMesh Pro Sprite Asset is loaded/created, you setup your lookup tables, I guess you just need to calculate UV’s. The Sprite references are all patched by Unity and point to the atlas at this time, in case of 1) atlasing is enabled or 2) the sprite comes from a image that contains multiple sprites.
You use the rect, texture and textureRect properties of each Sprite to figure out the UV’s. (The texture property either points to the texture or atlas). Since the Sprite List Entry contains the ID <> Sprite binding, you should have everything you need at this point.
Your Sprite drawing code needs to handle if sprites in one text are not on the same atlas. If you have this code, it should automatically work with individual textures too.
Hope it makes sense.
I’m not sure what you referring to. What offsets and scale do you mean?