public static GameObject BindScrollEvent(GameObject obj, UIEventHandle <PointerEventData> call) { if (null == obj) { return(null); } EventTriggerListener.Get(obj).onScroll.AddListener(call); return(obj); }
/// <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); }
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)); }
/// <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); } }
/// <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); }
public void RemoveListener(UIEventHandle <T> handle) { m_Handle -= handle; }
public void AddListener(UIEventHandle <T> handle) { m_Handle += handle; }