Fix autoload node cannot be accessed by plugin on start-up

(cherry picked from commit 2d4e573b20)
This commit is contained in:
Hilderin 2024-07-26 10:29:38 -04:00 committed by Rémi Verschelde
parent 2b4ade1ed6
commit 4a64c95732
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 3 additions and 1 deletions

View File

@ -457,7 +457,9 @@ void EditorAutoloadSettings::init_autoloads() {
for (const AutoloadInfo &info : autoload_cache) { for (const AutoloadInfo &info : autoload_cache) {
if (info.node && info.in_editor) { 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);
} }
} }
} }