58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace AI.StateMachineBehaviours
|
|
{
|
|
public class TestStateBehaviour : StateMachineBehaviour
|
|
{
|
|
private static readonly int IS_EXIT = Animator.StringToHash("IsExit");
|
|
|
|
[SerializeField] private InputActionReference inputAction;
|
|
|
|
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
Debug.Log("TestStateBehaviour OnStateEnter");
|
|
inputAction.action.Enable();
|
|
}
|
|
|
|
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
Debug.Log("TestStateBehaviour OnStateExit");
|
|
inputAction.action.Disable();
|
|
}
|
|
|
|
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
Debug.Log("TestStateBehaviour OnStateUpdate");
|
|
|
|
if (inputAction.action.triggered)
|
|
{
|
|
animator.SetBool(IS_EXIT, !animator.GetBool(IS_EXIT));
|
|
}
|
|
}
|
|
|
|
public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
Debug.Log("TestStateBehaviour OnStateMove");
|
|
}
|
|
|
|
public override void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
Debug.Log("TestStateBehaviour OnStateIK");
|
|
}
|
|
|
|
public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
|
|
{
|
|
base.OnStateMachineEnter(animator, stateMachinePathHash);
|
|
|
|
Debug.Log("TestStateBehaviour OnStateMachineEnter");
|
|
}
|
|
|
|
public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
|
|
{
|
|
base.OnStateMachineExit(animator, stateMachinePathHash);
|
|
|
|
Debug.Log("TestStateBehaviour OnStateMachineExit");
|
|
}
|
|
}
|
|
} |