• Unity
  • General question about changing attachment at runtime

Hi!
I have a spine project that uses a base skeleton and you can mix and match skins. The skeleton has 3 proportions using constraints(so they can use the same animations, but not the same outfits), so I'm suspecting there will be a lot of skins in the end (maybe 100).

In Unity I'm changing attachments(following mix-and-match equip example) to have any of the parts of the outfits look "damaged". But when profiling it seems every time it generates garbage and there is a little hiccup when copying the texture when cloning the attachment.

While it's not terrible, is there a better option here?

  • Adding a damaged part as skin looks like an option, but then that would multiply the skin by 5. Maybe it's not a problem other than a bit hard to manage in Spine?
  • Could one have, in the spine project, the damaged attachment in another slot and hide the original and show the damaged slot at runtime? Would this give less of a performance impact?

Any suggestions are appreciated!

Related Discussions
...

Are you repacking the skin after swapping attachments? While repacking saves the draw call overhead from using multiple textures, it will cause a single larger performance overhead when repacking the texture (cause a short "hiccup"). If multiple draw calls are not a problem, you might delay repacking to a later non-critical moment during gameplay.

DanielThomas wrote

Adding a damaged part as skin looks like an option, but then that would multiply the skin by 5. Maybe it's not a problem other than a bit hard to manage in Spine?

Performance-wise this should be the best option, since you can pre-arrange the grouping of attachments in your atlas textures as needed, and it comes with less overhead than when swapping attachments with Sprites and repacking the skin to a new one.

Regarding organization in Spine: You would then for sure use folders to arrange your skins in. This should then be just as equally easy or hard to manage as having lots of Sprite images in Unity.

DanielThomas wrote

Could one have, in the spine project, the damaged attachment in another slot and hide the original and show the damaged slot at runtime? Would this give less of a performance impact?

While you could go down that route, I don't think that this is a clean way to handle it.

There is no performance benefit at all, instead you will rather see a drawback for having 5x as many slots. Anyway, you will likely not receive any measurable performance difference by the number of slots when having the same number of attachments active. Performance will likely depend on other factors, such as the number of draw calls (different textures), the active vertex count, and the like. See the documentation on performance here for further info.

Thanks for the quick reply!
I'll continue with skins for this, as you suggested, thanks.

You're welcome, glad it helped.