示例#1
0
        public override void OnUpdate()
        {
            FixChangeAnimationBug();

            if (StartUpdate == false || eventIndex.Value == -1)
            {
                return;
            }


            if (NormalizedTime != null && NormalizedTime.Length == events.Length)
            {
                if (NormalizedTime[eventIndex.Value].Value != 0)
                {
                    for (int i = 0; i < Fsm.ActiveState.Actions.Length; i++)
                    {
                        if (Fsm.ActiveState.Actions[i] as AnimatorCrossFade != null)
                        {
                            AnimatorCrossFade data = Fsm.ActiveState.Actions[i] as AnimatorCrossFade;
                            if (_animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= NormalizedTime[eventIndex.Value].Value &&
                                _animator.GetCurrentAnimatorStateInfo(0).IsName(data.stateName.Value))
                            {
                                Fsm.Event(events[eventIndex.Value]);
                                Finish();
                            }
                            return;
                        }
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// 由于状态跳转动画播放和状态机跳转之间会产生异步导致动画播放卡主,所以进行动画状态判断,如果当前状态动画名和播放不一样,重新播放一边
 /// </summary>
 public void FixChangeAnimationBug()
 {
     for (int i = 0; i < Fsm.ActiveState.Actions.Length; i++)
     {
         if (Fsm.ActiveState.Actions[i] as AnimatorCrossFade != null)
         {
             AnimatorCrossFade data = Fsm.ActiveState.Actions[i] as AnimatorCrossFade;
             ///如果当前播放的动画状态与状态内设置不一 强制跳转动画
             if (!_animator.GetCurrentAnimatorStateInfo(0).IsName(data.stateName.Value))
             {
                 _animator.CrossFade(data.stateName.Value, 0);
             }
         }
     }
 }
示例#3
0
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            _animator = go.GetComponent <Animator>();

            for (int i = 0; i < Fsm.ActiveState.Actions.Length; i++)
            {
                if (Fsm.ActiveState.Actions[i] as AnimatorCrossFade != null)
                {
                    AnimatorCrossFade data = Fsm.ActiveState.Actions[i] as AnimatorCrossFade;
                    rootAnimationStateName = data.stateName.Value;
                }
            }
        }