diff --git a/Packages/Core/Runtime/Events/AtomEvent.cs b/Packages/Core/Runtime/Events/AtomEvent.cs index 0c52aadf..43a9b37c 100644 --- a/Packages/Core/Runtime/Events/AtomEvent.cs +++ b/Packages/Core/Runtime/Events/AtomEvent.cs @@ -67,6 +67,7 @@ namespace UnityAtoms foreach (var instance in _instances) { instance._replayBuffer.Clear(); + instance.UnregisterAll(); } } else if (state == PlayModeStateChange.EnteredPlayMode) @@ -74,6 +75,7 @@ namespace UnityAtoms foreach (var instance in _instances) { instance._replayBuffer.Clear(); + instance.UnregisterAll(); } } } @@ -82,14 +84,7 @@ namespace UnityAtoms private void OnDisable() { // Clear all delegates when exiting play mode - if (_onEvent != null) - { - var invocationList = _onEvent.GetInvocationList(); - foreach (var d in invocationList) - { - _onEvent -= (Action)d; - } - } + UnregisterAll(); } ///