浏览代码

Merge pull request #78787 from RedworkDE/net-non-tool-reload

C#: Fix reloading of non-tool scripts
Rémi Verschelde 2 年之前
父节点
当前提交
9a09ee5d02
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      modules/mono/csharp_script.cpp

+ 2 - 1
modules/mono/csharp_script.cpp

@@ -781,7 +781,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
 		MutexLock lock(script_instances_mutex);
 
 		for (SelfList<CSharpScript> *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<CSharpInstance *>(obj->get_script_instance());