private static void RemoveInstanceListener(int priority, EventComponent target, EventCallback callback) { SortedList <int, List <EventCallback> > instance; // See if we we have any events registered to this target already if (InstanceListeners.TryGetValue(target, out instance)) { List <EventCallback> listeners; if (instance.TryGetValue(priority, out listeners)) { listeners.Remove(callback); // Remove this priority if there are no more listeners if (listeners == null || listeners.Count == 0) { GlobalListeners.RemoveAt(priority); } } else { // Only log as a warning as this isn't technically an error, just something to keep an eye on as it shouldn't happen. Debug.LogWarning($"Trying to remove a callback from priority {priority}, which does not exist for {GenericTypeName}."); } } else { // Only log as a warning as this isn't technically an error, just something to keep an eye on as it shouldn't happen. Debug.LogWarning($"Trying to remove a callback from the instance {target.name} but there are no listeners for it"); } }
private static void RemoveGlobalListener(int priority, EventCallback callback) { List <EventCallback> listeners; if (GlobalListeners.TryGetValue(priority, out listeners)) { listeners.Remove(callback); // Remove this priority if there are no more listeners if (listeners == null || listeners.Count == 0) { GlobalListeners.RemoveAt(priority); } } else { // Only log as a warning as this isn't technically an error, just something to keep an eye on as it shouldn't happen. Debug.LogWarning($"Trying to remove a callback from priority {priority}, which does not exist for {GenericTypeName}."); } }