From 7f89294f1d15b1ad987334d70af97adcb87c2285 Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Fri, 7 Feb 2025 10:07:45 -0500 Subject: [PATCH] Fix Plugin Scripts load twice on startup --- editor/editor_node.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 961d81c034fd..c8b6227d1341 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3710,7 +3710,9 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // Only try to load the script if it has a name. Else, the plugin has no init script. if (script_path.length() > 0) { script_path = addon_path.get_base_dir().path_join(script_path); - scr = ResourceLoader::load(script_path, "Script", ResourceFormatLoader::CACHE_MODE_IGNORE); + // We should not use the cached version on startup to prevent a script reload + // if it is already loaded and potentially running from autoloads. See GH-100750. + scr = ResourceLoader::load(script_path, "Script", EditorFileSystem::get_singleton()->doing_first_scan() ? ResourceFormatLoader::CACHE_MODE_REUSE : ResourceFormatLoader::CACHE_MODE_IGNORE); if (scr.is_null()) { show_warning(vformat(TTR("Unable to load addon script from path: '%s'."), script_path));