Hi,
I have a game where I'm changing spine animation skins at runtime using SetSkin().
I have 3 skins which are basically different features/colours/animations of a cartoon face. The faces all appear in a grid, amongst other items. After a while the face will disappear from the grid, but can reappear again later (I'm object pooling them with a pool of about 20).
To begin with SetSkin() is working correctly and the faces change skin. However after a while of using SetSkin things start to deteriorate and I start seeing flashes of old skins/animations, or parts of the skin go missing. It feels like it happens randomly, and it can start happening at any time (but it's always after calling SetSkin a few times).
My guess is the object pooled faces are being reused and previous skins/animations are loitering and effecting things.
When I change skin I'm doing this -
_skeletonAnimation.skeleton.SetSkin(skin); // 1. Set your skin.
_skeletonAnimation.skeleton.SetSlotsToSetupPose(); // 2. Make sure it refreshes.
_skeletonAnimation.AnimationState.Apply(_skeletonAnimation.Skeleton); // 3. Make sure the attachments from your currently playing animation are applied.
If I don't use lines 2 and 3 above things are worse, so having these lines definitely helps but doesn't stop the issue.
Also beneficial is using 'clear state on disable' in the Unity editor. This seems to prevent things going wrong a bit longer.
I've tried using this but it doesn't help -
_skeletonAnimation.AnimationState.SetEmptyAnimations(0);
Any ideas would be appreciated. Ideally I would just like a way of completely resetting the skin in the OnEnable() method (when the object is released from the pool it is set to active and triggers this).
Thanks!