diff --git a/spine-lua/Skin.lua b/spine-lua/Skin.lua index c0090af53..f0c1c5fda 100644 --- a/spine-lua/Skin.lua +++ b/spine-lua/Skin.lua @@ -63,21 +63,24 @@ function Skin:getAttachment (slotIndex, name) end function Skin:attachAll(skeleton, oldSkin) - local slotIndex = 0 for i, slot in ipairs(skeleton.slots) do local slotAttachment = slot.attachment - if slotAttachment and slotIndex <= #oldSkin.attachments then - local dictionary = oldSkin.attachments[slotIndex] - for key, value in dictionary do - local skinAttachment = value - if slotAttachment == skinAttachment then - local attachment = getAttachment(slotIndex, key) - if attachment then slot.attachment = attachment end - break + if slotAttachment then + local dictionary = oldSkin.attachments[i] + if (dictionary) then + for key, value in pairs(dictionary) do + local skinAttachment = value + if slotAttachment == skinAttachment then + local attachment = self:getAttachment(i, key) + if attachment then + print("Set attachment " .. attachment.name .. " on slot " .. slot.data.name) + slot:setAttachment(attachment) + end + break + end end end end - slotIndex = slotIndex + 1 end end diff --git a/spine-lua/attachments/MeshAttachment.lua b/spine-lua/attachments/MeshAttachment.lua index dee325a01..400aa665e 100644 --- a/spine-lua/attachments/MeshAttachment.lua +++ b/spine-lua/attachments/MeshAttachment.lua @@ -103,6 +103,7 @@ function MeshAttachment:setParentMesh (parentMesh) if parentMesh then self.bones = parentMesh.bones self.vertices = parentMesh.vertices + self.worldVerticesLength = parentMesh.worldVerticesLength self.regionUVs = parentMesh.regionUVs self.triangles = parentMesh.triangles self.hullLength = parentMesh.hullLength