• Unity
  • Applying skin clears previous colours

Related Discussions
...

Hi there,

I'm currently setting some slot colours on my animation via code. (Also it seems that this tints any colours applied in Spine, rather than replacing them, is that correct?) These then seem to be cleared when I clear my current skin (Skin.Clear()) and append new skins to it. However the slots that are being reset aren't actually a part of the skins (they are always on).

The simple work around is to grab the current colours before applying the skin reset, and reapply them afterwards. But I just wanted to find out if I was doing something incorrectly?

Thanks!

skeleton.SetSlotsToSetupPose resets slot colors.
That's because a slot's color is animatable and does have a setup pose that it can reset to.

The way you're doing it is fine.
In fact, your code should really hold that color information itself rather than applying it on the slot and then forgetting it.

But if you want a version of SetSlotsToSetupPose that doesn't reset colors, it would look like this:

foreach (var slot in skeleton.Slots) {
   var slotData = slot.Data;
   slot.Attachment = slotData.AttachmentName == null ? null : skeleton.GetAttachment(slotData.Index, slotData.AttachmentName);
}
Pharan wrote

The way you're doing it is fine.
In fact, your code should really hold that color information itself rather than applying it on the slot and then forgetting it.

Yeah I am already storing the colour currently, and can reapply it trivially. I just wondered if there is something else I should be doing. But I'm fine with just reapplying the colour if that's an appropriate way to do it!