/// <summary> /// 移除事件 /// </summary> /// <param name="eventType">事件类别</param> /// <param name="callback">回调函数</param> public void removeEventListener(string eventType, UEventListener.EventListenerDelegate callback) { UEventListener eventListener = this.getListener(eventType); if (eventListener != null) { eventListener.OnEvent -= callback; } }
/// <summary> /// 侦听事件 /// </summary> /// <param name="eventType">事件类别</param> /// <param name="callback">回调函数</param> public void addEventListener(string eventType, UEventListener.EventListenerDelegate callback) { UEventListener eventListener = this.getListener(eventType); if (eventListener == null) { eventListener = new UEventListener(eventType); eventListenerList.Add(eventListener); } eventListener.OnEvent += callback; }