added player and danger platfroms
This commit is contained in:
40
Assets/Scripts/GameInput/InputReader.cs
Normal file
40
Assets/Scripts/GameInput/InputReader.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user