예제 #1
0
 /// <summary>
 /// 清空指定事件的所有监听
 /// </summary>
 /// <param name="type"></param>
 public void Clear(E_Event_Type type)
 {
     if (eventDic.ContainsKey(type))
     {
         eventDic.Remove(type);
     }
 }
예제 #2
0
 /// <summary>
 /// 移除事件监听
 /// </summary>
 /// <param name="type"></param>
 /// <param name="fun"></param>
 public void RemoveEventListener(E_Event_Type type, UnityAction fun)
 {
     if (eventDic.ContainsKey(type))
     {
         (eventDic[type] as EventInfo).action -= fun;
     }
 }
예제 #3
0
 /// <summary>
 /// 触发事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="info"></param>
 public void EventTrigger(E_Event_Type type)
 {
     if (eventDic.ContainsKey(type))
     {
         if ((eventDic[type] as EventInfo).action != null)
         {
             (eventDic[type] as EventInfo).action();
         }
     }
 }
예제 #4
0
 /// <summary>
 /// 触发事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="info"></param>
 public void EventTrigger <T>(E_Event_Type type, T info)
 {
     if (eventDic.ContainsKey(type))
     {
         if ((eventDic[type] as EventInfo <T>).action != null)
         {
             (eventDic[type] as EventInfo <T>).action(info);
         }
     }
 }
예제 #5
0
 /// <summary>
 /// 添加事件监听
 /// </summary>
 /// <param name="type"></param>
 /// <param name="fun"></param>
 //public void AddEventListener( E_Event_Type type, UnityAction<object> fun )
 public void AddEventListener(E_Event_Type type, UnityAction fun)
 {
     if (eventDic.ContainsKey(type))
     {
         (eventDic[type] as EventInfo).action += fun;
     }
     else
     {
         eventDic.Add(type, new EventInfo(fun));
     }
 }
예제 #6
0
 /// <summary>
 /// 添加事件监听
 /// </summary>
 /// <param name="type"></param>
 /// <param name="fun"></param>
 //public void AddEventListener( E_Event_Type type, UnityAction<object> fun )
 public void AddEventListener <T>(E_Event_Type type, UnityAction <T> fun)
 {
     //if (eventDic.ContainsKey(type))
     //    eventDic[type] += fun;
     //else
     //    eventDic.Add(type, fun);
     if (eventDic.ContainsKey(type))
     {
         (eventDic[type] as EventInfo <T>).action += fun;
     }
     else
     {
         eventDic.Add(type, new EventInfo <T>(fun));
     }
 }