Context: say you\'re checking whether \"W\" is pressed on the keyboard, the most common way to check this is through the following code:
void Update(){
i
I created an simples script to trigger simple event. I used OnguiGUI instead of Update. See it bellow!
using UnityEngine;
using UnityEngine.Events;
public class TriggerKey : MonoBehaviour
{
[Header("----Add key to trigger on pressed----")]
public string key;
// Unity event inspector
public UnityEvent OnTriggerKey;
public void OnGUI()
{ // triiger event on trigger key
if (Event.current.Equals(Event.KeyboardEvent(key)))
{
OnTriggerKey.Invoke();
print("test trigger btn");
}
}
}