24 lines
617 B
C#
24 lines
617 B
C#
public class InputManager : MonoBehaviour
|
|
{
|
|
private InputActions _inputActions;
|
|
|
|
public event EventHandler<Vector2> OnMovementInput;
|
|
public event EventHandler OnFireButtonPressed;
|
|
|
|
private void Awake()
|
|
{
|
|
_inputActions = new InputActions();
|
|
_inputActions.Player.Movement.performed += ctx => OnMovementInput?.Invoke(ctx.ReadValue<Vector2>());
|
|
_inputActions.Player.Fire.performed += ctx => OnFireButtonPressed?.Invoke();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_inputActions.Enable();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_inputActions.Disable();
|
|
}
|
|
} |