@[cancellato]
It actually does more than set a field. spine-runtimes/Slot.java at 3.7-beta
But yeah, it is cheap. But if it was necessary to do that every frame, I'm not sure if you might be better off not keying the attachment at all.
However, removing the attachment entries from the skin is pretty ideal. I think you were on the right track.
Note that the SetAttachmentNull method is not really necessary. Spine 3.6 and 3.7, you should have the needed extension method. Just make sure you have the AttachmentTools
namespace added:
// above
using namespace Spine.Unity.Modules.AttachmentTools;
int slotIndex; // can get this from skeleton.FindSlotIndex
string keyName; // this is the name of the skin placeholder
yourSkin.RemoveAttachment(slotIndex, keyName); // Sets the skin entry to null.
// Any time you make changes to a skin and want them to be reflected on a skeleton immediately,
// you need to tell the skeleton to update its attachments based on the skin.
skeleton.SetSlotsToSetupPose(); // use setup pose attachments
//skeletonAnimation.AnimationState.Apply(skeleton); // Usually not required but certain use cases need this so attachments from the current animation's keys are immediately applied.
// Alternatively, if you know which slot you want to update, you can just update that slot.
slot.SetToSetupPose();
// or...
// slot.Attachment = skeleton.GetAttachment(slotIndex, slot.Data.AttachmentName);
An additional thing to consider is that if your skeleton's default skin has an attachment, setting the attachment value on the skeleton's active skin to null, or removing that value, will cause it to fall back to the attachment found in the default skin.
In the near future, there are runtime changes and API additions planned in the base runtime for this: [runtimes] Add API to create combined skin from multiple other skins · #841