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