예제 #1
0
 public static GameObject BindScrollEvent(GameObject obj, UIEventHandle <PointerEventData> call)
 {
     if (null == obj)
     {
         return(null);
     }
     EventTriggerListener.Get(obj).onScroll.AddListener(call);
     return(obj);
 }
예제 #2
0
        /// <summary>
        /// 卸载特定事件
        /// </summary>
        /// <param name="eventId">事件列表id</param>
        /// <param name="eventHandler">指定事件</param>
        /// <returns></returns>
        public static bool UnRegisteredEvent(string eventId, UIEventHandle eventHandler)
        {
            List <UIEventHandle> handlerList;

            if (dic.TryGetValue(eventId, out handlerList))
            {
                if (handlerList.Contains(eventHandler))
                {
                    handlerList.Remove(eventHandler);
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        public static GameObject BindScrollEvent(RectTransform trans, string name, UIEventHandle <PointerEventData> call)
        {
            if (null == trans)
            {
                return(null);
            }
            RectTransform findTrans = Control(name, trans);

            if (!CheckComponent(findTrans, trans.name, name))
            {
                return(null);
            }
            return(BindScrollEvent(findTrans.gameObject, call));
        }
예제 #4
0
        /// <summary>
        /// 注册事件,同一个事件可以重复注册,多次注册多次执行,注意注册次数
        /// </summary>
        /// <param name="eventId">时间id</param>
        /// <param name="eventHandler">事件</param>
        public static void RegisteredEvent(string eventId, UIEventHandle eventHandler)
        {
            List <UIEventHandle> handler;

            if (dic.TryGetValue(eventId, out handler))
            {
                handler.Add(eventHandler);
            }
            else
            {
                List <UIEventHandle> uiEventList = new List <UIEventHandle>();
                uiEventList.Add(eventHandler);
                dic.Add(eventId, uiEventList);
            }
        }
예제 #5
0
        /// <summary>
        /// 检查的当前事件的注册数量
        /// </summary>
        /// <param name="eventId">事件列表id</param>
        /// <param name="eventHandler">事件</param>
        /// <returns></returns>
        public static int GetSameEventCount(string eventId, UIEventHandle eventHandler)
        {
            List <UIEventHandle> handlerList;
            int count = 0;

            if (dic.TryGetValue(eventId, out handlerList))
            {
                for (int i = 0; i < handlerList.Count; i++)
                {
                    if (handlerList[i] == eventHandler)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
예제 #6
0
 public void RemoveListener(UIEventHandle <T> handle)
 {
     m_Handle -= handle;
 }
예제 #7
0
 public void AddListener(UIEventHandle <T> handle)
 {
     m_Handle += handle;
 }