コード例 #1
0
        public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
        {
            base.OnStateMachineEnter(animator, stateMachinePathHash);

            var smao = new StateMachineActionObject()
            {
                Animator = animator,
                PathHash = stateMachinePathHash,
                State    = AnimatorState.Enter
            };

            foreach (var action in Actions)
            {
                action.Execute(smao);
            }
        }
コード例 #2
0
        public override void Execute(StateMachineActionObject smao)
        {
            foreach (var evt in Events)
            {
                var message           = evt.CreateInstance(false);
                var serializableEvent = message as ISerializableEvent;
                var animatorEvent     = message as IAnimatorEvent;

                if (Identifier)
                {
                    serializableEvent.Source = Identifier;
                }
                else
                {
                    serializableEvent.Source = smao.Animator.gameObject;
                }
                animatorEvent.Animator   = smao.Animator;
                animatorEvent.LayerIndex = smao.LayerIndex;
                animatorEvent.State      = smao.State;
                EventSystem.Publish(message);
            }
        }
コード例 #3
0
ファイル: Repeat.cs プロジェクト: chaolunner/UnityFramework
        private void TryRepeat(StateMachineActionObject smao)
        {
            var delay = System.TimeSpan.FromSeconds(smao.StateInfo.length + Random.Range(Interval.Min, Interval.Max));

            if (Repeater != null)
            {
                Repeater.Dispose();
            }

            Repeater = Observable.Timer(delay).Subscribe(_ =>
            {
                if (smao.Animator.State(smao.LayerIndex) == smao.StateInfo.fullPathHash)
                {
                    smao.Animator.Play(smao.StateInfo.fullPathHash, smao.LayerIndex, 0f);
                    TryRepeat(smao);
                }
                else if (Repeater != null)
                {
                    Repeater.Dispose();
                }
            }).AddTo(smao.Animator);
        }
コード例 #4
0
        public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            base.OnStateMove(animator, stateInfo, layerIndex);

            if (!IgnoreWeight && layerIndex > 0 && animator.GetLayerWeight(layerIndex) <= 0)
            {
                return;
            }

            var smao = new StateMachineActionObject()
            {
                Animator   = animator,
                PathHash   = stateInfo.fullPathHash,
                StateInfo  = stateInfo,
                LayerIndex = layerIndex,
                State      = AnimatorState.Move
            };

            foreach (var action in Actions)
            {
                action.Execute(smao);
            }
        }
コード例 #5
0
        public override void Execute(StateMachineActionObject smao)
        {
            var animatorStateEvent = new AnimatorStateEvent(smao.Animator, smao.PathHash, smao.StateInfo, smao.LayerIndex, smao.State);

            EventSystem.Send(animatorStateEvent);
        }
コード例 #6
0
 public override void Execute(StateMachineActionObject smao)
 {
     smao.Animator.SetBool(ParameterHash, IsOn);
 }
コード例 #7
0
        public override void Execute(StateMachineActionObject smao)
        {
            var value = Random.Range(RangedValue.Min, RangedValue.Max);

            smao.Animator.SetInteger(ParameterHash, value);
        }
コード例 #8
0
 public abstract void Execute(StateMachineActionObject smao);
コード例 #9
0
 public override void Execute(StateMachineActionObject smao)
 {
     Debug.Break();
 }
コード例 #10
0
ファイル: Repeat.cs プロジェクト: chaolunner/UnityFramework
 public override void Execute(StateMachineActionObject smao)
 {
     TryRepeat(smao);
 }
コード例 #11
0
 public override void Execute(StateMachineActionObject smao)
 {
     Debugger.Log(Type, Message, "Mecanator", null);
 }