Exemplo n.º 1
0
        void OnAnimationFinished(string anim)
        {
            int newAnim = 0;

            switch (anim)
            {
            case "idle":
                newAnim = 2;
                break;

            case "run_forward":
                newAnim = 1;
                break;

            case "run_backward":
                newAnim = 3;
                break;

            case "run_left":
                newAnim = 4;
                break;

            case "run_right":
                newAnim = 0;
                break;
            }
            if (crossFade)
            {
                meshAnimator.Crossfade(newAnim);
            }
            else
            {
                meshAnimator.Play(newAnim);
            }
        }
        protected virtual void LateUpdate()
        {
            AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);

#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
            int id = stateInfo.nameHash;
#else
            int id = stateInfo.fullPathHash;
#endif
            if (animHashes.ContainsKey(id))
            {
                if (cAnim != animHashes[id])
                {
                    cAnim = animHashes[id];
                    if (crossFade)
                    {
                        meshAnimator.Crossfade(animHashes[id]);
                    }
                    else
                    {
                        meshAnimator.Play(animHashes[id]);
                    }
                }
            }
        }