From 2d4e573b20284409110cf63a81587adb76288753 Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:29:38 -0400 Subject: [PATCH] Fix autoload node cannot be accessed by plugin on start-up --- editor/editor_autoload_settings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index b62351256e2b..32b2133f234b 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -457,7 +457,9 @@ void EditorAutoloadSettings::init_autoloads() { for (const AutoloadInfo &info : autoload_cache) { if (info.node && info.in_editor) { - callable_mp((Node *)get_tree()->get_root(), &Node::add_child).call_deferred(info.node, false, Node::INTERNAL_MODE_DISABLED); + // It's important to add the node without deferring because code in plugins or tool scripts + // could use the autoload node when they are enabled. + get_tree()->get_root()->add_child(info.node); } } }