Not really, no. I call SetAnimation in the Complete event handler, but I believe that is ok as long as you don't do it in End event handler. I'll try to isolate this particular sequence and see if it works.
17 Feb 2017, 15:14
I've thrown together this component quickly as it's what I'm doing but without a bunch of other logic, and the issue is still there.
This is the code:
public class DELETE_ME : MonoBehaviour
{
public SkeletonAnimation _characterAnimation;
public string _workingAnimName = "Working";
public string _workingSpecialAnimName = "Special Action_hatOn";
private int _numWorkingCyclesComplete;
void Start ()
{
_numWorkingCyclesComplete = 0;
_characterAnimation.state.Start += HandleOnAnimationStarted;
_characterAnimation.state.Complete += HandleOnAnimationComplete;
PlayAnimation(_workingAnimName, true);
}
private void PlayAnimation(string animName, bool loop)
{
_characterAnimation.state.SetAnimation(0, animName, loop);
}
private void HandleOnAnimationStarted(Spine.TrackEntry trackEntry)
{
Debug.LogWarning("'" + trackEntry.Animation.name +"' Animation started.");
}
private void HandleOnAnimationComplete(Spine.TrackEntry trackEntry)
{
Debug.LogWarning("'" + trackEntry.Animation.name +"' Animation completed.");
if (trackEntry.Animation.name == _workingAnimName)
{
_numWorkingCyclesComplete++;
if (_numWorkingCyclesComplete == 5)
{
PlayAnimation(_workingSpecialAnimName, false);
_numWorkingCyclesComplete = 0;
}
}
else if (trackEntry.Animation.name == _workingSpecialAnimName)
{
_numWorkingCyclesComplete = 0;
PlayAnimation(_workingAnimName, true);
}
}
}
With this code, I noticed one different thing. Start is only called when it first runs, then it is never called again. In my original code, it would be called when the working animation started, but never for working special animation.
I've tried this on our own animation and also on spineboy (using the run and jump animations) and both behave the same.