Greetings!
We are using a slightly modified legacy SpriteAttacher and I have a question about how to unattach a sprite. I tried adding a null setter if the sprite is null, but that didn't seem to work. Here is my attach code with a comment above where i am trying to clear the slot:
public void Attach(Sprite sprite, T_EquipSlots equipSlot)
{
var skeletonComponent = GetComponent<ISkeletonComponent>();
Shader attachmentShader = Shader.Find(DefaultStraightAlphaShader);
var slot = skeletonComponent.Skeleton.FindSlot(_SLOT_TYPE_TO_NAME[equipSlot]);
if (sprite == null)
{
// If sprite is null unattach [NOT WORKING]
slot.Attachment = null;
return;
}
// This is required to prevent the arms getting distorted with the wrong rotation
RegionAttachment attachment;
if (slot.Attachment != null)
{
float rotation = ((RegionAttachment)slot.Attachment).Rotation;
attachment = sprite.ToRegionAttachmentPMAClone(attachmentShader, rotation: rotation);
} else
{
attachment = sprite.ToRegionAttachmentPMAClone(attachmentShader);
}
slot.Attachment = attachment;
}
Do you know what I need to do in order to properly remove an attachment?