using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.Events; public abstract class GameState : StateMachineBehaviour { public string currentStateName ; protected Animator ActiveAnimator; public abstract void OnGameStateEnter(); public abstract void OnGameStateUpdate(); public abstract void OnGameStateExit(); public abstract void ResetState(); public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("进入" + currentStateName); ActiveAnimator = animator; ResetState(); // by default all state machines will have a Next trigger // ActiveAnimator.ResetTrigger(Animator.StringToHash(currentStateStr)); OnGameStateEnter(); } public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ActiveAnimator = animator; OnGameStateUpdate(); } public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("离开" + currentStateName); ActiveAnimator = animator; OnGameStateExit(); } }