You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

2 years ago
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();
}
}