コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
        /// <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;
        }