public static void UnRegister(EventType1 eventType, OneObjEventHandler handler) { if (EventMap1.ContainsKey(eventType)) { EventMap1[eventType] -= handler; } }
/// <summary> /// 触发事件;事件接受一个参数 /// </summary> /// <param name="eventType">事件类型</param> /// <param name="obj">传递给所有事件回调函数的参数</param> public static void Send(EventType1 eventType, object obj) { if (EventMap1.ContainsKey(eventType) && EventMap1[eventType] != null) { try { EventMap1[eventType](obj); } catch (Exception ex) { Debug.LogError($"An exception occured while event({eventType}) send. {ex}"); } } }
/// <summary> /// 触发事件;事件接受一个参数 /// </summary> /// <param name="eventType">事件类型</param> /// <param name="obj">传递给所有事件回调函数的参数</param> public static void Send(EventType1 eventType, object obj) { if (EventMap1.ContainsKey(eventType) && EventMap1[eventType] != null) { try { EventMap1[eventType](obj); } catch (Exception ex) { Debug.LogError("An exception occured while event(" + eventType.ToString() + ") send. " + ex.ToString()); } } }