public static void AddListener(object obj, string eventName, Delegate action) { //if (obj == null) return; //EventDispatcher eventDispatcher = obj.AddMissingComponent<EventDispatcher>(); //eventDispatcher.Add(eventName, action); EventBatchStatic batch = new EventBatchStatic(action, obj); HashSet <EventBatchStatic> batches; if (!eventBatchStaticDict.TryGetValue(eventName, out batches)) { batches = new HashSet <EventBatchStatic>(); eventBatchStaticDict.Add(eventName, batches); } if (batches.Contains(batch)) { return; } batches.Add(batch); }
public static void AddListener(object obj, string eventName, Delegate action) { //if (obj == null) return; //EventDispatcher eventDispatcher = obj.AddMissingComponent<EventDispatcher>(); //eventDispatcher.Add(eventName, action); EventBatchStatic batch = new EventBatchStatic(action, obj); if (!eventBatchStaticDict.TryGetValue(eventName, out var batches)) { batches = new List <EventBatchStatic>(); eventBatchStaticDict.Add(eventName, batches); batches.Add(batch); } else { if (batches.Contains(batch)) { Debug.LogError($"Duplicate Add found event name {eventName}"); return; } batches.Add(batch); } }
private static bool isMatchToRemoveAll(EventBatchStatic b) { return(true); }
private static bool isMatchToRemove(EventBatchStatic b) { return(cTarget == b.target && cDelegate == b._delegate); }