Is there any news on when (if at all possible) sprite atlas support will arrive for the unity runtime?
It seems like it'd be a really useful feature however when I tried to pack some sprites everything broke. I assume its not implemented yet.
Is there any news on when (if at all possible) sprite atlas support will arrive for the unity runtime?
It seems like it'd be a really useful feature however when I tried to pack some sprites everything broke. I assume its not implemented yet.
What exactly did you do when you said "I tried to pack some sprites"? What did you want to accomplish?
Have you tried Spine's Texture Atlas Packerto customize the packed atlas?
We have an issue ticket here for Unity Sprite Atlas support, but I think you are describing another use case.
I wanna pack sprites I add to unity into an atlas to hopefully increase performance since I don't wanna be doing any packing or exporting from Spine.
I'm following one of the recommended guides to create a base template in spine, and then at runtime generate the skin for them.
The thing I noticed was the each material created for a added sprite attachment is in its own separate material. I was hoping there was a way to pack them all in an atlas and then have a shared material for those segments.
I know I can dynamically pack all the sprites and base material texture into a single texture/material (from what I saw of the mix and match demo)
However having many spine objects each with a unique texture/material seems like it increase draw calls more then if I had the baseTemplate material, and then all the rest of the sprite pieces were packed into a single atlas.
(So essentially having 2 materials used for all sprites)
Does this make sense and is achievable?
We would recommend using Spine's Texture Atlas Packer as mentioned above, if you already know which images shall go into which (shared common) atlas.
So if you want to have 2 materials for all sprites, you can create the two atlases in the Spine Editor, via the Texture Atlas Packer.
Or did I misunderstand you there?
Well I don't wanna have to rely on spine to export out all the sprites in an atlas.
I'm dealing with hundreds of sprites, and to be able to pack them in unity would be more efficient I think. Especially since I won't know all the assets from the start, I plan to add more in updates over time.
If you want to pack them in Unity, you can also pack them to a single atlas and single material via code, as in the Mix and Match
example (in the Mix and Match Equip
example, you have to hit the Done
Button to trigger optimization and repacking of the atlas).
I was hoping there was a way to pack them all in an atlas and then have a shared material for those segments.
..
I know I can dynamically pack all the sprites and base material texture into a single texture/material (from what I saw of the mix and match demo)
Your sentences above seem somewhat contradictory, but I assume that you just missed to trigger the repacking. Note that in the Mix and Match Equip
sample, at first when clicking items there are multiple materials, when hitting the Done
button it is recombined to a single material and atlas.
See this sample code used in Mix and Match Equip
:
spine-runtimes/EquipsVisualsComponentExample.cs at 3.7
Oh no I'm well aware of how the single atlas packing worked in mix and match.
My point was if I packed each spine character individually into one atlas and had many on screen
That's about a draw call per character since each material and texture is unique
I wanted to be able to pack using unitys sprite atlas pack so that when I do combine, it could hopefully take advantage of the existing atlas
If all my equipment sprites were packed together in theory I could have many characters rendered via just two materials
(The base spine material and the equipment sprite atlas material)
Vs. Unique atlas for every character and or no atlas at all
Wouldn't this in theory work? The spine attachment meshes are capable of taking a sprite from the spine sprite atlas so what's stopping it from using unitys is my question.
I'd just like to pack my sprites in unity rather then spine due to the way everything I have is setup (through so's which I assign a sprite too)
Anisoft написалIf all my equipment sprites were packed together in theory I could have many characters rendered via just two materials
(The base spine material and the equipment sprite atlas material) [...] Wouldn't this in theory work?
Yes, if everthing fits into the two atlases, of course this would work. You could already do this with the Spine API as I described above, which you want to avoid as you said.
Anisoft написалThe spine attachment meshes are capable of taking a sprite from the spine sprite atlas so what's stopping it from using unitys is my question.
It is simply not implemented yet, but planned in the issue ticket listed in my topmost posting. In the meantime I suggested to use Spine's already existing features to achieve your desired goal, otherwise you will have to wait for the feature to arrive (or implement your own solution, which we do not recommend).
However, note that if your items are interleaved with the character assets and you have separated character and items into two atlases, then you will get a draw call each time your draw order switches from the character to an item or back.
Okay so that makes things clear. It seems I was confused about the Spine API for packing. I had thought it only worked for a single material/texture packing for one character only, but it seems your saying I can pack multiple. (I shoulda experimented with that)
Ah right the draw order of stuff does make a difference for calls. Damn I forgot about that. I guess it is just more optimal then to pack everything into a single texture per character (unless I can find a way to pack all sprites and the template sprites into some sort of mega atlas to reduce calls down into just 1)
In theory I imagine it is possible to do that too if it was needed. I could generate a single atlas for all shared characters I think and reduce draw calls for large amounts.
Tho in my case I don't think its too necessary, Ill stick with a generated atlas per character for now.
One last question, spine allows you to have meshes link to other meshes in the editor. This is great for having cloth type deformations apply to anything that copies that mesh.
Since I'm using placeholders and generating at runtime, does the api support converting sprites into linked meshes? I tried looking it up and at least at the time it seemed a bit all over the place as to what specifically the api was and or what you even can do (all these forum posts dated back a few years) I remember a youtube video talking about how it was possible in v5 but not v4, but the api was different then so I'm not entirely sure where to start.
Most of my sprites plan to be animated a bunch using linked meshes to make the characters more life like so its definitely a big part of what I'd need.
Alright thank you for taking the time to help me. Sorry for the constant misunderstandings! You and the entire team are amazing as usual!
Thanks for the kind words. We all know it can be frustrating when questions and answers go in the wrong direction, language can be tricky.
The GetRemappedClone
method can be used to create linked meshes as well, it's actually the default parameter:
AttachmentTools.cs#L1098
In the Mix and Match
example it's just leaving many parameters at their default values, thus hiding the cloneMeshAsLinked = true
part:
MixAndMatch.cs#L97
Sweet thank you so much for your help, Ima test this out soon!