• Runtimes
  • Getting all Attachements in a Slot

I have a slot with multiple image attachments under it, to randomise which head is drawn on enemies. Is there a way of accessing all total attachements?

Ideally I'd do:

HeadSlot.attachment = "HeadGraphic_" + Random.Range(1, HeadSlot.AllAttachments.Count);

Is that doable? I can't seem to find a way...

Related Discussions
...

Attachments from the skeleton JSON data are stored in skins. The SkeletonData has a list of skins. The skin named "default" has all the attachments that don't have a skin in Spine. In spine-csharp, Skin has FindNamesForSlot(slotIndex, List<String>). The names of attachments for the slot are added to the list (done this way to avoid allocation). There is also FindAttachmentsForSlot(slotIndex, List<Attachment> attachments).

Note you can create an attachment dynamically, or even grab one attachment and shove it in a different slot that it was originally intended, so there is technically no list of all attachments for a slot. I think the above will do what you want.

This should work brilliantly, I'll take a look. Thanks hugely for your help, Nate 🙂

d