An atlas cannot be just turned into a skin. An atlas is a list of regions (not region attachments), each with a name and UVs for the 4 corners. A skin is a name -> attachment map. An attachment, such as a region attachment, has many properties, such as x, y, rotation, scale, which texture atlas region to use (stored in rendererObject
), etc. See:
Spine Runtimes Guide
Loading Image
The skeleton data has attachment data inside it. SkeletonJson loads the skeleton data and uses an AttachmentLoader to create the attachments and assign them regions from an atlas.
If you have multiple atlases, one thing you can do is use an AttachmentLoader that looks in each one until it finds a region for the attachment, then it assigns the region to the attachment. Copy AtlasAttachmentLoader and hack it up to do that. You would create a SkeletonJson, give it your AttachmentLoader, then give it your JSON and it will give you a SkeletonData that has all the attachments with regions assigned from any number of atlases.
Another way to do it is to get an attachment from your SkeletonData, make a copy of it, then change the copy attachment's region (rendererObject
) to that of whatever atlas you like. You can then add the attachment to a skin, or set it directly on a skeleton by getting a slot and calling Slot setAttachment
.
Yet another way to do it is to write code to create an attachment entirely from scratch. However, this is difficult because it is hard to visualize where to place the attachment, at what rotation, etc. This is why it's more common to setup an attachment in the Spine editor, then make a copy at runtime and change the region/rendererObject. Again, once you have the attachment you can add it to a skin or call Slot setAttachment
.
All of these setups require understanding how things work and write a fair amount of code. That is why badlogic said it is not easy. You'll need to read through the code to understand how SkeletonJson loads attachments and what the AttachmentLoader does.