private void removeListener(Dictionary <Int32, EventAction> eventHandlers, Int32 evtType, EventAction handler) { EventAction exists = getHandler(eventHandlers, evtType); if (exists != null) { if (exists.GetInvocationList().Contains(handler)) { exists -= handler; eventHandlers[evtType] = exists; } if (exists == null || exists.GetInvocationList().Length == 0) { eventHandlers.Remove(evtType); } } }
private void removeListener(Dictionary <string, EventAction> eventDic, string evtId, EventAction handler) { EventAction eventAction = getHandler(eventDic, evtId); if (eventAction != null) { if (eventAction.GetInvocationList().Contains(handler)) { eventAction -= handler; eventDic[evtId] = eventAction; } if (eventAction == null || eventAction.GetInvocationList().Length == 0) { eventDic.Remove(evtId); } } }
private void addListener(Dictionary <string, EventAction> eventDic, string evtId, EventAction handler) { EventAction eventAction = getHandler(eventDic, evtId); if (eventAction != null) { if (!eventAction.GetInvocationList().Contains(handler)) { eventAction += handler; } else { Debug.LogWarning($"handler:{nameof(handler)} has already exist with evtId {evtId},you can not add again"); } } else { eventAction = handler; } eventDic[evtId] = eventAction; }
private void addListener(Dictionary <Int32, EventAction> eventHandlers, Int32 evtType, EventAction handler) { EventAction exists = getHandler(eventHandlers, evtType); if (exists != null) { if (!exists.GetInvocationList().Contains(handler)) { exists += handler; } else { UnityEngine.Debug.LogError("多次添加事件:" + evtType.ToString()); } } else { exists = handler; } eventHandlers[evtType] = exists; }