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

    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));
        }
    }

使用

StartCoroutine(PublicFunc.YieldAniFinish(m_ani, "Shang", () => { TaskFinish(); }));

你可能感兴趣的:(Unity3D实用技术笔记)