From e1338ac0eb2313795b7060bc98211495fa45e384 Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 18 Jun 2018 15:52:46 -0300 Subject: [PATCH] Fix order to register autoloads in-editor --- editor/editor_autoload_settings.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 5b6594d2336..30983ca1493 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -742,12 +742,30 @@ EditorAutoloadSettings::EditorAutoloadSettings() { info.name = name; info.path = path; info.order = ProjectSettings::get_singleton()->get_order(pi.name); - info.node = _create_autoload(path); + + if (info.is_singleton) { + // Make sure name references work before parsing scripts + for (int i = 0; i < ScriptServer::get_language_count(); i++) { + ScriptServer::get_language(i)->add_named_global_constant(info.name, Variant()); + } + } + + autoload_cache.push_back(info); + } + + List to_add; + for (List::Element *E = autoload_cache.front(); E; E = E->next()) { + AutoLoadInfo &info = E->get(); + + info.node = _create_autoload(info.path); if (info.node) { Ref