gustavim15

Hello,

I started to use Spine with Unity now, and I was trying to attach a weapon on my character's hand.
I was following this tutorial:



When he is creating the Attacher Script, he use skeletonRenderer.skeleton.AttachUnitySprite(slot, sprite);

I tried to do it, but on my Unity (2017.1) only appears SetAttachment and GetAttachment. I'm doing something wrong, or there's a new way to do this Weapon Attachment?

Thank you!
gustavim15
Posts: 4

Pharan

That tutorial is quite old.

If you're trying to do equips, I recommend the Mix and Match workflow.

But if you just need this one simple thing, the code would look like this:
// first, make sure to add using Spine.Unity.Modules.AttachmentTools; on top of your script

var slot = skeletonAnimation.Skeleton.FindSlot("slot you want");
var attachment = yourUnitySprite.ToRegionAttachment(materialWithPropertiesYouWantToUse);
slot.Attachment = attachment;
This peels away a bit of the abstractedness but lets you know you're creating a new RegionAttachment type from a Material, and putting that in the slot.
User avatar
Pharan

Pharan
Posts: 4444

Mitch

We should probably revise the tutorials heh
User avatar
Mitch

Mitch
Posts: 966

gustavim15

Pharan wrote:That tutorial is quite old.

If you're trying to do equips, I recommend the Mix and Match workflow.

But if you just need this one simple thing, the code would look like this:
// first, make sure to add using Spine.Unity.Modules.AttachmentTools; on top of your script

var slot = skeletonAnimation.Skeleton.FindSlot("slot you want");
var attachment = yourUnitySprite.ToRegionAttachment(materialWithPropertiesYouWantToUse);
slot.Attachment = attachment;
This peels away a bit of the abstractedness but lets you know you're creating a new RegionAttachment type from a Material, and putting that in the slot.
Hey, thank you for reply.
I tried to use it, but nothing happens into the scene... So I followed this "Mix and Match workflow", but for some reason, my sword sprite appears compressed on the scene, like if I scaled Y. I don't know why. There are any video using this new sprite attachment system?
Thank you!

---

Mitch wrote:We should probably revise the tutorials heh
Ohh, It would be nice... Every tutorial I see, it's from 2 years ago :sweat:
Thank you!
gustavim15
Posts: 4


Return to Unity