コード例 #1
0
        public override void OnStep(float deltaTime, bool shouldPause)
        {
            if (timeElapsedDuringDelay < DelaySeconds)
            {
                timeElapsedDuringDelay += deltaTime;
                return;
            }

            // NOTE: Pause is temporarily unsupported!
            if (!isPlayed)
            {
                AnimationComponent.Play(members[0].Clip.name);
                currentPlayingIndex = 0;
                isPlayed            = true;
            }

            if (currentPlayingIndex < playForList.Count && timeElapsedInSec >= playForList[currentPlayingIndex])
            {
                var nextIndex = currentPlayingIndex + 1;
                AnimationComponent.CrossFade(members[nextIndex].Clip.name, members[currentPlayingIndex].CrossFadeLength);
                currentPlayingIndex++;
            }

            if (IsDone())
            {
                FinalizeAction();
            }

            timeElapsedInSec += deltaTime;
        }
コード例 #2
0
        public void Play(AnimationDataObject _data)
        {
            if (_data == null || _data.Enabled == false || _data.InterfaceType == AnimationInterfaceType.NONE)
            {
                return;
            }

            if (_data.InterfaceType == AnimationInterfaceType.LEGACY)
            {
                if (AnimationComponent == null)
                {
                    PrintErrorLog(this, "Missing Animation Component!");
                    return;
                }

                AnimationComponent[_data.Animation.Name].wrapMode = _data.Animation.wrapMode;
                AnimationComponent[_data.Animation.Name].speed    = _data.Animation.Speed;               //Mathf.Clamp( m_BehaviourData.MoveVelocity. controller.velocity.magnitude, 0.0, runMaxAnimationSpeed);
                AnimationComponent.CrossFade(_data.Animation.Name, _data.Animation.TransitionDuration);
            }
            else if (_data.InterfaceType == AnimationInterfaceType.CLIP)
            {
                if (AnimationComponent != null && _data.Clip.Clip != null)
                {
                    AnimationComponent.AddClip(_data.Clip.Clip, _data.Clip.Clip.name);
                    AnimationComponent.CrossFade(_data.Clip.Clip.name, _data.Clip.TransitionDuration);
                }
            }
            else if (_data.InterfaceType == AnimationInterfaceType.MECANIM)
            {
                if (AnimatorComponent == null || AnimatorComponent.runtimeAnimatorController == null || !AnimatorComponent.isInitialized)
                {
                    return;
                }

                if (AnimatorComponent.applyRootMotion != _data.Animator.ApplyRootMotion)
                {
                    AnimatorComponent.applyRootMotion = _data.Animator.ApplyRootMotion;
                }

                if (_data.Animator.Type == AnimatorControlType.DIRECT)
                {
                    UpdateAnimatorState(_data.Animator);
                }
                else if (_data.Animator.Type == AnimatorControlType.ADVANCED)
                {
                    UpdateAnimatorParameter(_data.Animator, false);
                }
            }
            else if (_data.InterfaceType == AnimationInterfaceType.CUSTOM)
            {
                if (OnCustomAnimation != null)
                {
                    OnCustomAnimation();
                }
            }
        }
コード例 #3
0
 public override void FireEvent()
 {
     if (AnimationComponent != null && !string.IsNullOrEmpty(_Animation))
     {
         var state = AnimationComponent[_Animation];
         if (state != null)
         {
             ApplyStateParameters(state);
             AnimationComponent.CrossFade(_Animation, _FadeLenght, _Mode);
         }
     }
 }