Describe the bug
Apologies for sticking my nose into your code, but I'm having a problem where BoltNetwork.RemoveGlobalEventCallback<T>(Action<T> callback) would not find the callback and throw a warning Could not find delegate registered as callback.
I believe the problem is in the if (!this._callbacks.TryGetValue(typeof (T), out callbackWrapperList)) line of the following function (EventDispatcher.Remove):
public void Remove<T>(Action<T> callback) where T : Event
{
List<EventDispatcher.CallbackWrapper> callbackWrapperList;
if (!this._callbacks.TryGetValue(typeof (T), out callbackWrapperList))
{
for (int index = 0; index < callbackWrapperList.Count; ++index)
{
if ((Delegate) callbackWrapperList[index].Original == (Delegate) callback)
{
callbackWrapperList.RemoveAt(index);
return;
}
}
}
BoltLog.Warn("Could not find delegate registered as callback");
}
To Reproduce
Steps to reproduce the behavior:
BoltNetwork.AddGlobalEventCallback<ReliableStateSyncEvent>(OnEvent);
// The following call throws a warning and does not remove the callback:
BoltNetwork.RemoveGlobalEventCallback<ReliableStateSyncEvent>(OnEvent);
Expected behavior
The callback would be removed.
Actual behavior
The warning is thrown, the callback is not removed.
Screenshots
Not applicable.
Desktop (If applicable, please complete the following information):
OS: Windows 10
Version: 10.0.19041
Smartphone (If applicable, please complete the following information):
Describe the bug Apologies for sticking my nose into your code, but I'm having a problem where
BoltNetwork.RemoveGlobalEventCallback<T>(Action<T> callback)
would not find the callback and throw a warningCould not find delegate registered as callback
.I believe the problem is in the
if (!this._callbacks.TryGetValue(typeof (T), out callbackWrapperList))
line of the following function (EventDispatcher.Remove
):To Reproduce Steps to reproduce the behavior:
Expected behavior The callback would be removed.
Actual behavior The warning is thrown, the callback is not removed.
Screenshots Not applicable.
Desktop (If applicable, please complete the following information):
Smartphone (If applicable, please complete the following information):
Additional context