I'm trying to use SpriteAttacher to attach a sprite "new_sword" into the "weapon" slot. At first, during animation "attack", slot "weapon" only has 1 attachment "original_sword", I can create a new attachment from "new_sword" and then attach it to slot "weapon". But now, my "attack" animation is more complicated. During first 10 frames, slot "weapon" is attached with "original_sword" and in last 10 frames, it is attached with "original_sword_2". How can attach 2 new sprites: "new_sword" and "new_sword_2" corresponding to first 10 and last 10 frames of that animation ?
Attach to a slot that has 2 attachments during animation
- Editado
You should use a skin. The animation shows/hides the skin placeholders, then the actual attachments used come from the skin. You would set the new_sword
attachment in the skin at runtime instead of setting it on the slot.
But can I make a new skin and set attachments for that skin from script ? I'm studying CustomSkin.cs but it seems copy skin data from original skeletondata asset instead of create a new skin.
Step 1. Animate using skins in the editor
Step 2. Use your own skin at runtime.
This way, animations will try to use whatever skin data is set. So if you set or create your own skin, it will follow that.
Replace the two sword attachments in your own skin with your new sword atttachments. and it will use them appropriately.
This work-in-progress documentation has a sample of this: https://github.com/pharan/spine-unity-docs/blob/master/Mix-and-Match.md
Let us know if something is unclear or confusing about it.