diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 87b5ac74354..35fd63047e1 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -833,6 +833,25 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { return; } + // Add all script types to script bridge before reloading exports, + // so typed collections can be reconstructed correctly regardless of script load order. + for (Ref &scr : to_reload) { + if (!scr->get_path().is_empty() && !scr->get_path().begins_with("csharp://")) { + String script_path = scr->get_path(); + + bool valid = GDMonoCache::managed_callbacks.ScriptManagerBridge_AddScriptBridge(scr.ptr(), &script_path); + + if (valid) { + scr->valid = true; + + CSharpScript::update_script_class_info(scr); + + // Ensure that the next call to CSharpScript::reload will refresh the exports + scr->reload_invalidated = true; + } + } + } + List> to_reload_state; for (Ref &scr : to_reload) {