public void AddListener(EventDispatcherNode dis, EventDispatcherNode.EventListenerDele dele, string type , int _priority = 0, bool _dispatchOnce = false) { if (!dis.HasListener(type, dele)) { var data = new EventListenerData(dis, dele, type); mlistener.Add(data); dis.AttachListener(type, dele, _priority, _dispatchOnce); } else { Debug.LogWarning("添加消息失败重复添加消息id=" + type); } }
public void DetachListener(EventDispatcherNode dis, EventDispatcherNode.EventListenerDele dele, string type) { if (dis.HasListener(type, dele)) { dis.DetachListener(type, dele); for (var i = 0; i < mlistener.Count; i++) { var data = mlistener[i]; if (data.dis == dis && data.type == type && data.dele == dele) { mlistener.RemoveAt(i); i--; } } } }