Initial commit
This commit is contained in:
14
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.asset
Normal file
14
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.asset
Normal file
@@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 94786f68f321b5249b0997193bb0036b, type: 3}
|
||||
m_Name: InputReaderSO
|
||||
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.InputReaderSO
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0805b8520c4573a4e99ea101253c2c9f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.cs
Normal file
57
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
[CreateAssetMenu(fileName = "InputReaderSO", menuName = "Scriptable Objects/InputReaderSO")]
|
||||
public class InputReaderSO : ScriptableObject, IInputReader, GameInputAction.IPlayerActions
|
||||
{
|
||||
public GameInputAction action;
|
||||
|
||||
public event Action OnJumpPerformed;
|
||||
public bool isShooting { get; private set; }
|
||||
public Vector2 moveInput { get; private set; }
|
||||
public Vector2 lookInput { get; private set; }
|
||||
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
action = new GameInputAction();
|
||||
}
|
||||
action.Enable();
|
||||
action.Player.SetCallbacks(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
action.Player.Disable();
|
||||
}
|
||||
public void OnMove(InputAction.CallbackContext context)
|
||||
{
|
||||
moveInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
|
||||
public void OnLook(InputAction.CallbackContext context)
|
||||
{
|
||||
lookInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if(context.performed)
|
||||
{
|
||||
OnJumpPerformed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnShoot(InputAction.CallbackContext context)
|
||||
{
|
||||
isShooting = context.ReadValueAsButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94786f68f321b5249b0997193bb0036b
|
||||
Reference in New Issue
Block a user