void Awake() { upPressed = new UnityEventWrapper <bool>(); downPressed = new UnityEventWrapper <bool>(); leftPressed = new UnityEventWrapper <bool>(); rightPressed = new UnityEventWrapper <bool>(); spacePressed = new UnityEvent(); zPressed = new UnityEvent(); }
public static void StartListening <T, U>(string eventName, UnityAction <T, U> listener) { UnityEventBase thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { ((UnityEvent <T, U>)thisEvent).AddListener(listener); } else { thisEvent = new UnityEventWrapper <T, U>(); ((UnityEvent <T, U>)thisEvent).AddListener(listener); Instance.eventDictionary.Add(eventName, thisEvent); } }
public static void StartListening <T>(string eventName, UnityAction <T> listener) { string log = "Start listenning"; UnityEventBase thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { log += " again"; ((UnityEvent <T>)thisEvent).AddListener(listener); } else { thisEvent = new UnityEventWrapper <T>(); ((UnityEvent <T>)thisEvent).AddListener(listener); Instance.eventDictionary.Add(eventName, thisEvent); } log += " to " + eventName + "."; Debug.Log(log); }