I need to call a function immediately after animator animation finished playing, I know I could solve this by adding an event to my animation, but I try it without.
How can I find out if the current animator animation is playing?
On normal legacy animations I solved it by writing a coroutine:
public static IEnumerator playAndWaitForAnim(Animation anim, string clipName, Action callback)
{
anim.Play(clipName);
//Wait until Animation is done Playing
while (anim.IsPlaying(clipName)) {
yield return null;
}
//Done playing. Do something below!
callback();
}
Which I use like this:
StartCoroutine(AnimationHelper.playAndWaitForAnim(
myAnimation,
"ToSettings",
() => {
Debug.Log ("Finished playing");
}
));
But how does this work with mecanim animator animations?