• Editor
  • Spine character with many, many images

I'm new to Spine so sorry for the ignorance. My character will have many, many different items that they can hold (100+ let's say), and it's my understanding that spine uses an atlas file that will be packed together in limited size. This will be an issue since there's too many items to fit in the atlas.

What's the solution to this in Spine? Or is this something that needs to be addressed in the actual game engine?

Thank you! 🙂

Related Discussions
...

There are many solutions of varying complexity, depending on what you need.

100 isn't a huge amount and may fit on a single atlas page. If not, you may be able to put some parts on a separate atlas page (using folders). Eg, if you can put all weapons on their own atlas page, rendering your skeleton would draw from one atlas page, then draw the weapon from a second atlas page, then draw the rest of the skeleton from the first atlas page. That's 3 texture changes to render the skeleton, but that may be acceptable.

Otherwise, you can customize the AttachmentLoader, see here:
http://esotericsoftware.com/spine-loading-skeleton-data#AttachmentLoader
The AtlasAttachmentLoader expects to find all regions loaded from a texture atlas at the time the skeleton data is loaded. You can provide your own that doesn't have that requirement. The attachments are all loaded with the skeleton data, but not configured with a texture region. Before drawing, you need to configure them. You'd outfit your character, pack at runtime only the images the character uses into an atlas, then use that atlas. If you are using Unity, some of this is done for you (see the examples). I described some of how it works here (and elsewhere many times):
https://esotericsoftware.com/forum/d/23863-swap-texture-atlas-scale-at-runtime/2

If you have many images, like thousands, setting them up in Spine can be tedious. Instead you can use a template attachment and replace it at runtime with the actual image you want to use. See:
http://esotericsoftware.com/spine-runtime-skins

    a year later

    Nate

    Hi Nate,

    Recently, I’ve been researching how to dynamically load atlases. After searching through numerous forum posts, I came across several solutions, such as directly replacing the skeletonDataAsset or replacing spineAtlasAsset separately (both based on Unity runtime). However, in some of your responses, I noticed new approaches: customizing the AttachmentLoader and "using template attachments and replacing them with the actual image you want to use at runtime."

    After reading through your explanations and the documentation, I still don’t fully understand these two approaches.

    1. Based on my understanding of the Spine runtime code, it seems that texture loading is not related to the setup of the AttachmentLoader. You mentioned that Unity has a relevant example; could you tell me the name of the example?

    2. I only found the concept of template images in the documentation here: https://esotericsoftware.com/spine-runtime-skins#Creating-attachments. Is there a related example or practical implementation available?

      jonomidi Based on my understanding of the Spine runtime code, it seems that texture loading is not related to the setup of the AttachmentLoader. You mentioned that Unity has a relevant example; could you tell me the name of the example?

      Spine Examples/Other Examples/Mix and Match and Mix and Match Equip are two examples showing replacement of original attachments with Attachments created from Unity Sprite images.