50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace DefaultNamespace
|
|
{
|
|
public class Test : UnityEngine.StateMachineBehaviour
|
|
{
|
|
private static readonly int IS_EXIT_ID = Animator.StringToHash("isExit");
|
|
|
|
[SerializeField] private InputAction _action;
|
|
|
|
public override void OnStateEnter(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo,
|
|
int layerIndex)
|
|
{
|
|
Debug.Log("OnStateEnter");
|
|
_action.Enable();
|
|
}
|
|
|
|
public override void OnStateExit(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo,
|
|
int layerIndex)
|
|
{
|
|
Debug.Log("OnStateExit");
|
|
_action.Disable();
|
|
}
|
|
|
|
public override void OnStateUpdate(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo,
|
|
int layerIndex)
|
|
{
|
|
Debug.Log($"{Time.time}: OnStateUpdate {Time.frameCount}");
|
|
|
|
if (_action.triggered)
|
|
{
|
|
animator.SetBool(IS_EXIT_ID, !animator.GetBool(IS_EXIT_ID));
|
|
}
|
|
}
|
|
|
|
public override void OnStateMove(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo,
|
|
int layerIndex)
|
|
{
|
|
Debug.Log($"{Time.time}: OnStateMove {Time.frameCount}");
|
|
}
|
|
|
|
public override void OnStateIK(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo,
|
|
int layerIndex)
|
|
{
|
|
Debug.Log("OnStateIK");
|
|
}
|
|
}
|
|
} |