unity3d:监听当前动画执行完毕回调

2023-08-24 14:23:42 浏览数 (1)

代码语言:javascript复制
    public static IEnumerator YieldAniFinish(Animator ani,string aniName, UnityAction action)
    {
        yield return null;
        AnimatorStateInfo stateinfo = ani.GetCurrentAnimatorStateInfo(0);

        if (stateinfo.IsName(aniName) && (stateinfo.normalizedTime > 1.0f))
        {
            action();
        }
        else
        {
            Instance.StartCoroutine(YieldAniFinish(ani,aniName, action));
        }
    }

使用

代码语言:javascript复制
StartCoroutine(PublicFunc.YieldAniFinish(m_ani, "Shang", () => { TaskFinish(); }));

0 人点赞