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]);
                    }
                }
            }
        }
    private void Update()
    {
        if (_animator != null && _meshAnimator != null)
        {
            string animationName = _animator.GetCurrentAnimatorClipInfo(0)[0].clip.name;
            if (_currentAnimation != animationName)
            {
                _currentAnimation = animationName;
                _meshAnimator.Play(animationName);
            }

            _meshAnimator.SetTime((_animator.GetCurrentAnimatorStateInfo(0).normalizedTime % 1) * _animator.GetCurrentAnimatorClipInfo(0)[0].clip.length);
        }

        bool activateMeshAnimator = (!_animator.IsInTransition(0));

        _meshRenderer.enabled = activateMeshAnimator;
        foreach (GameObject skinnedMeshRendere in _skinnedMeshRenderers)
        {
            skinnedMeshRendere.SetActive(!activateMeshAnimator);
        }
    }
Exemplo n.º 3
0
 void Start()
 {
     meshAnimator.Play();
     meshAnimator.OnAnimationFinished += OnAnimationFinished;
 }