/// <summary> /// 添加事件监听 /// </summary> /// <param name="eventType"></param> /// <param name="del"></param> public void AddEvent(EventType eventType, EventHandleDel del) { if (!m_EventDic.ContainsKey(eventType)) { m_EventDic.Add(eventType, new List <EventHandleDel>()); } var list = m_EventDic[eventType]; if (!list.Contains(del)) { list.Add(del); } }
/// <summary> /// 删除事件监听 /// </summary> /// <param name="eventType"></param> /// <param name="del"></param> public void RemoveEvent(EventType eventType, EventHandleDel del) { List <EventHandleDel> list = null; if (m_EventDic.TryGetValue(eventType, out list)) { for (int i = 0; i < list.Count; i++) { if (list[i].Target == del.Target) { list.RemoveAt(i); } } } }