void Start() { myEvent = new UnityEvent(); myEvent.AddListener(FireFunction); myEvent.AddListener(AnotherFireFunction); paramsEvent = new ParamsEvent(); paramsEvent.AddListener(FireFunctionWithParams); myEvent.Invoke(); paramsEvent.Invoke("hello", 22); paramsEvent.Invoke("jdawgs", 8008135); }
public static void TriggerEvent(string eventName, ParamsObject paramsObj = null) { ParamsEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(paramsObj); } if (instance.lastEventValues != null) { instance.lastEventValues[eventName] = paramsObj; } }
public void TriggerEvent(string eventName, ParamsObject paramsObj = null) { if (eventDictionary == null) { eventDictionary = new Dictionary <string, ParamsEvent>(); lastEventValues = new Dictionary <string, ParamsObject>(); } ParamsEvent thisEvent = null; if (eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(paramsObj); lastEventValues[eventName] = paramsObj; } }