Files
Cielonos/Assets/Shift - Complete Sci-Fi UI/Scripts/Event/PressKeyEvent.cs
SoulliesOfficial 6d7ebc5825 Passion & UI
2026-06-12 17:11:39 -04:00

28 lines
633 B
C#

using UnityEngine;
using UnityEngine.Events;
namespace Michsky.UI.Shift
{
public class PressKeyEvent : MonoBehaviour
{
[Header("Key")]
public KeyCode hotkey;
public bool pressAnyKey;
public bool invokeAtStart;
[Header("Action")]
public UnityEvent pressAction;
void Start()
{
if (invokeAtStart)
pressAction?.Invoke();
}
void Update()
{
if (pressAnyKey && Input.anyKeyDown) { pressAction?.Invoke(); }
else if (Input.GetKeyDown(hotkey)) { pressAction?.Invoke(); }
}
}
}