WinterJamSnowman/Assets/Scripts/LemonGenericLib/DebugUtilities/KeyCodeInputController.cs

48 lines
1.1 KiB
C#
Raw Normal View History

2023-01-24 13:51:46 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Lemon.GenericLib.Utility {
public class KeyCodeInputController : MonoBehaviour
{
[Header("controlls list")]
[SerializeField] private KeyCodeControll[] keyCodeControlls;
private void Update()
{
if (Input.anyKeyDown)
{
//CheckInit();
foreach (var controlls in keyCodeControlls)
{
if (Input.GetKeyDown(controlls.KeyCode))
{
controlls.InvokeKeyCodeFunction();
}
}
}
}
[System.Serializable]
private class KeyCodeControll
{
[SerializeField] private KeyCode keyCode;
[SerializeField] private UnityEvent InputFunctions;
public KeyCode KeyCode { get => keyCode; set => keyCode = value; }
public void InvokeKeyCodeFunction()
{
InputFunctions?.Invoke();
}
}
}
}