We have some Game Objects with Skeleton Graphics on them and a script that plays the Spine animations from their beginning whenever the Game Object is activated.
Here's what that code looks like, stripped down:
private void OnEnable()
{
Play();
}
public void Play(string spineAnimationName = null, string animationTrigger = null, Action onAnimationCompleted = null)
{
foreach (IAnimationStateComponent spineObject in spineArray)
{
int trackIndex = 0;
foreach (TrackEntry track in spineObject.AnimationState.Tracks)
{
// Rewinds the Spine animation
track.TrackTime = 0;
if (spineAnimationName.HasValue())
{
spineObject.AnimationState.SetAnimation(trackIndex++, spineAnimationName, false);
}
}
}
}
The problem we're seeing is that when the Game Object is activated by a Unity animation, we see a single frame flicker of the last frame that the Spine Animation was in when it was previously deactivated.
There is no flicker if you manually activate and deactivate the Game Object through the Inspector.
It feels like maybe Unity is evaluating native animations one frame faster than Spine is evaluating the updated mesh / bone positions? So the Game Object becomes active and visible, but Spine hasn't had a chance to reflect the updated TrackTime.
Anyway, we've tried all kinds of stuff, like Update, LateUpdate, Reset, etc. and we're out of ideas.
Thanks for your help!
Also, sorry if this is too similar to this recent topic: http://esotericsoftware.com/forum/Animation-flickers-on-enable-9407
I wasn't sure if our situation applied, considering we aren't calling any Animator commands.
We did try the Update and LateUpdate suggestions from that topic and it just caused our Spine animations to stop playing properly.