public void RemoveListener(e_EventID e_Event, Action <object> callback) { if (_listener.ContainsKey(e_Event)) { _listener[e_Event] -= callback; } }
public void RegisterListener(e_EventID eventID, Action <object> callback) { if (_listener.ContainsKey(eventID) == false) { _listener.Add(eventID, null); } _listener[eventID] += callback; }
public void PostEvent(e_EventID eventID, object param = null) { if (_listener.ContainsKey(eventID) == false) { Debug.LogError("Not contain key: " + eventID); return; } Action <object> callbacks = _listener[eventID]; if (callbacks != null) { callbacks(param); } else// if Listener not contain event of eventID =>remove { _listener.Remove(eventID); } }
/// <summary> /// post event without parameter /// </summary> /// <param name="mono"></param> /// <param name="e_Event"></param> /// <param name="param"></param> public static void PostEvent(this MonoBehaviour mono, e_EventID e_Event) { OberserverMng.singleton.PostEvent(e_Event); }
public static void RegisterListener(this MonoBehaviour mono, e_EventID e_Event, Action <object> callback) { OberserverMng.singleton.RegisterListener(e_Event, callback); }