using System; using UnityEngine; using UnityEngine.InputSystem; public class InputManager : MonoBehaviour { private InputActions _actions; public Vector2 Movement { get; private set; } public event Action OnFire; private void Awake() { _actions = new InputActions(); // Movement _actions.Player.Movement.performed += OnMovementPerformed; _actions.Player.Movement.canceled += OnMovementCanceled; // Fire _actions.Player.Fire.performed += ctx => OnFire?.Invoke(); } public void OnEnable() { _actions.Enable(); } public void OnDisable() { _actions.Disable(); } private void OnMovementPerformed(InputAction.CallbackContext ctx) { Movement = ctx.ReadValue(); } private void OnMovementCanceled(InputAction.CallbackContext ctx) { Movement = Vector2.zero; } }