testusername123 I had a 'pre-idle' animation where I had keyframed everything off
Glad you found it! Generally you don't want any animation to key everything. It's inefficient and what is "everything" often changes, so you'd need to remember to add things to such an animation and you'll surely forget. Mainly though, it is inefficient. You can use
It works, but maybe you set a different attachment afterward.
testusername123 I think that SetAnimation updates the slot attachments in late-update or something
SetAnimation does it immediately, where "it" is that it sets up the AnimationState tracks. It does not apply the animation.
Take a look at the spine-unity lifecycle. The Unity components are likely applying animations for you. You'll need to use the right callbacks so your code runs after animations are applied.
testusername123 I just noticed decided to remove the egg keyframe for the hat entirely, and I just manage it in code now.
That's a fine solution. Why were you keying it in an animation if you want to control it in code? If it really does need to be keyed in animations, for example to show a hat with a different perspective mid-animation, then you can do that. A "skin" is an intermediate layer between an animation and the actual attachment used. Instead of the animation keying a specific attachment named "red hat front", it keys a skin placeholder named eg "hat front". When the animation is applied, the timeline will call
skeleton.SetAttachment(slot, "hat front"). See the docs on that method:
Since it calls
GetAttachment, look at that method too:
GetAttachment looks in the skin for the specified name ("hat front") to find the actual attachment. This allows you to put any attachment you want in the skin for "hat front", decoupled from what the animation keys.
Given that, the way it works is you create a skin and populate it with the attachments you want. It sounds like you are using the skins you defined in the Spine editor. Instead of doing that, you create an empty skin and add stuff to it. For example, you can add one or more skins defined in the Spine editor, and/or you can set specific attachments for the hat skin placeholders. See:
I suggest using a skin for a collection of attachments. For your hat, say you have skin placeholders
hat front and
hat side, then you create a skin called
red hat and populate it with red hats for those placeholders. Create another skin called
blue hat and populate the attachments. Then at runtime you create an empty skin and add either the
red hat or
blue hat skin to it.
You don't have to combine skins like this, but it's convenient. You could instead add the attachments for the
hat front and
hat side skin placeholders instead of using a skin. The skin just groups it for convenience in Spine. In Spine you can apply multiple skins at once, so you can preview and animate with different skin combinations:
All that said, if you have many attachments (eg 1000+) then setting them all up in the editor is tedious. With careful organization you can make a setup that uses template images in Spine, so you can visualize and animation, then at runtime you configure everything dynamically.