- Изменено
Problems attachment from different Atlas - Unity
Greetings fellow Spiners,
I'm having some problems with the Unity 3D c# runtime. I'm trying to load a different atlas (created in the Editor) and using one of the images there as an attachment, but it turns invisible when I try to attach it.
// Doesn't work
AtlasAttachmentLoader loader = new AtlasAttachmentLoader( atlas.GetAtlas() );
RegionAttachment att2 = loader.NewAttachment(skeletonAnimation.skeleton.Data.Skins[0], AttachmentType.region, "hat") as RegionAttachment;
I'm able to attach something I get from the it's own skeleton, but not from a different atlas nor it's own atlas.
// Works
Skeleton s = new Skeleton(dataAsset.GetSkeletonData(true));
Attachment att1 = s.GetAttachment("hat", "hat");
skeletonAnimation.skeleton.FindSlot("left hand").Attachment = att1;
Pretty lost on this one, if you guys could provide some help I'll mail you a shot of Caipirinha :beer: .
Thanks in advance!
If NewAttachment doesn't throw an exception, it should have found the region in the atlas. How do you set the attachment on the slot? You'll need to use:
skeleton.FindSlot("slotName").Attachment = att2;
Make sure att2 isn't null, else it will clear the attachment for the slot.