Files
HelixJump/Assets/Scripts/GameInput/InputReader.cs
2025-12-11 12:20:01 -08:00

41 lines
971 B
C#

using System;
using UnityEngine;
using UnityEngine.InputSystem;
[CreateAssetMenu(fileName = "InputReader", menuName = "Scriptable Objects/InputReader")]
public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActions
{
public Action<Vector2> 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<Vector2>();
}
}