/// <summary> /// Stop listening specified event. /// </summary> /// <param name="eventName">Event name.</param> /// <param name="listener">Listener.</param> public static void StopListening(string eventName, UnityAction <GameObject, object> listener) { MyEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
private void Update() { if (Input.GetKeyDown(KeyCode.A)) { e.Broadcast("Test1"); } else if (Input.GetKeyDown(KeyCode.B)) { e.Broadcast("Test2", "assdsd"); e.RemoveListener("Test1", Handler); } }
public static void RemoverEvento(string nome, UnityAction <GameObject, string> evento) { if (instancia == null) { return; } MyEvent esteEvento = null; if (instancia.eventos.TryGetValue(nome, out esteEvento)) { esteEvento.RemoveListener(evento); } }
/// <summary> /// Stop listening specified event. /// </summary> /// <param name="eventName">Event name.</param> /// <param name="listener">Listener.</param> public static void StopListening(string eventName, UnityAction <GameObject, string> listener) { if (Instantiate == null) { return; } MyEvent thisEvent = null; if (Instantiate.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StopListening(string eventName, UnityAction <object> listener) { if (eventManager == null) { return; } MyEvent thisEvent = null; if (Singleton.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
// Start is called before the first frame update void Start() { evt = new MyEvent(); evt.AddListener(PrintNumber); evt.RemoveListener(PrintNumber); }