using System; using UnityEngine; using UnityEngine.InputSystem; [CreateAssetMenu(fileName = "InputReader", menuName = "Scriptable Objects/InputReader")] public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActions { public Action OnDragValueChanged; public Vector2 _dragInput; public Vector2 dragInput { get=> _dragInput; private set { _dragInput = value; OnDragValueChanged?.Invoke(_dragInput); } } private GameInput inputActions; private void OnEnable() { if(inputActions==null) { inputActions = new GameInput(); inputActions.Player.SetCallbacks(this); } inputActions.Enable(); } private void OnDisable() { inputActions?.Player.Disable(); } public void OnDrag(InputAction.CallbackContext context) { dragInput = context.ReadValue(); } }