diff --git a/Source/Engine/Scripting/BinaryModule.cpp b/Source/Engine/Scripting/BinaryModule.cpp index 5bbaf8d0b..e9465096f 100644 --- a/Source/Engine/Scripting/BinaryModule.cpp +++ b/Source/Engine/Scripting/BinaryModule.cpp @@ -693,6 +693,14 @@ void BinaryModule::Destroy(bool isReloading) } } + // Remove any scripting events + for (auto i = ScriptingEvents::EventsTable.Begin(); i.IsNotEnd(); ++i) + { + const ScriptingTypeHandle type = i->Key.First; + if (type.Module == this) + ScriptingEvents::EventsTable.Remove(i); + } + // Unregister GetModules().RemoveKeepOrder(this); }