/// <summary> /// 移除事件侦听 /// </summary> /// <param name="_eventId">事件ID</param> /// <param name="_event">事件</param> public void RemoveListener(int _eventId, StrayFogEventHandler _event) { if (mEventHandlerMaping.ContainsKey(_eventId) && mEventHandlerMaping[_eventId].Contains(_event)) { mEventHandlerMaping[_eventId].Remove(_event); } }
/// <summary> /// 添加事件侦听 /// </summary> /// <param name="_eventId">事件枚举</param> /// <param name="_event">事件</param> public void AddListener(int _eventId, StrayFogEventHandler _event) { if (!mEventHandlerMaping.ContainsKey(_eventId)) { mEventHandlerMaping.Add(_eventId, new List <StrayFogEventHandler>()); } if (!_event.IsValid()) { #if UNITY_EDITOR Debug.LogError(string.Format("注册消息【{0}】失败=>Delegate.Target is null.", _eventId)); #endif } else if (!mEventHandlerMaping[_eventId].Contains(_event)) { mEventHandlerMaping[_eventId].Add(_event); } }