From 42b4fc0710b1319185409c336eb94ac6e13b9106 Mon Sep 17 00:00:00 2001 From: Lucas Melo <42917725+shoyguer@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:15:23 -0300 Subject: [PATCH] Fix 'Could not resolve script' error after renaming a preloaded script --- modules/gdscript/gdscript.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 4fa88bb580..743d61ae6e 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1104,6 +1104,12 @@ void GDScript::set_path(const String &p_path, bool p_take_over) { String old_path = path; path = p_path; path_valid = true; + + String old_base = GDScript::canonicalize_path(old_path); + if (!old_base.is_empty() && fully_qualified_name.begins_with(old_base)) { + fully_qualified_name = GDScript::canonicalize_path(p_path) + fully_qualified_name.substr(old_base.length()); + } + if (is_root_script()) { GDScriptCache::move_script(old_path, p_path); }