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(); } } } }