From 60b9eb169e8bcfe69cadea4e6f0f676cda6e993d Mon Sep 17 00:00:00 2001 From: RedworkDE <10944644+RedworkDE@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:46:43 +0200 Subject: [PATCH] C# Fix reloading of non-tool scripts --- modules/mono/csharp_script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index d9c372e930b1..3e032f213b44 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -781,7 +781,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { MutexLock lock(script_instances_mutex); for (SelfList *elem = script_list.first(); elem; elem = elem->next()) { - bool is_reloadable = false; + // Do not reload scripts with only non-collectible instances to avoid disrupting event subscriptions and such. + bool is_reloadable = elem->self()->instances.size() == 0; for (Object *obj : elem->self()->instances) { ERR_CONTINUE(!obj->get_script_instance()); CSharpInstance *csi = static_cast(obj->get_script_instance());