关于Unity的Animation如何检测动画的开始播放和结束播放

 public void PlayAnimation(Animation animation, string clipName, Action startAct, Action endAct)
    {
        StartCoroutine(PlayAnimationItor(animation, clipName, startAct, endAct));
    }


    private IEnumerator PlayAnimationItor(Animation animation, string clipName, Action startAct, Action endAct)
    {
        startAct?.Invoke();

        AnimationState animationState = animation[clipName];
        animation.Play(clipName);

        yield return StartCoroutine(new WaitForEndOfAnim(animationState));

        endAct?.Invoke();
    }

猜你喜欢

转载自blog.csdn.net/qq_37335907/article/details/125142409