diff --git a/spine-c/include/spine/Skin.h b/spine-c/include/spine/Skin.h index 649b15574..6fb3de156 100644 --- a/spine-c/include/spine/Skin.h +++ b/spine-c/include/spine/Skin.h @@ -46,6 +46,9 @@ void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment /* Returns 0 if the attachment was not found. */ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name); +/* Returns 0 if the slot or attachment was not found. */ +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex); + /** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ void Skin_attachAll (const Skin* self, struct Skeleton* skeleton, const Skin* oldSkin); diff --git a/spine-c/src/spine/Skin.c b/spine-c/src/spine/Skin.c index c91814d91..2cec61bf4 100644 --- a/spine-c/src/spine/Skin.c +++ b/spine-c/src/spine/Skin.c @@ -88,6 +88,19 @@ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* nam return 0; } +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex) { + const _Entry* entry = SUB_CAST(_Internal, self) ->entries; + int i = 0; + while (entry) { + if (entry->slotIndex == slotIndex) { + if (i == attachmentIndex) return entry->name; + i++; + } + entry = entry->next; + } + return 0; +} + void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) { const _Entry *entry = SUB_CAST(_Internal, oldSkin) ->entries; while (entry) {