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); } }
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); } }
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); }
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); } }
public override void Execute(StateMachineActionObject smao) { var animatorStateEvent = new AnimatorStateEvent(smao.Animator, smao.PathHash, smao.StateInfo, smao.LayerIndex, smao.State); EventSystem.Send(animatorStateEvent); }
public override void Execute(StateMachineActionObject smao) { smao.Animator.SetBool(ParameterHash, IsOn); }
public override void Execute(StateMachineActionObject smao) { var value = Random.Range(RangedValue.Min, RangedValue.Max); smao.Animator.SetInteger(ParameterHash, value); }
public abstract void Execute(StateMachineActionObject smao);
public override void Execute(StateMachineActionObject smao) { Debug.Break(); }
public override void Execute(StateMachineActionObject smao) { TryRepeat(smao); }
public override void Execute(StateMachineActionObject smao) { Debugger.Log(Type, Message, "Mecanator", null); }