Fix order to register autoloads in-editor
This commit is contained in:
parent
a74e151420
commit
e1338ac0eb
1 changed files with 22 additions and 2 deletions
|
@ -742,12 +742,30 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
||||||
info.name = name;
|
info.name = name;
|
||||||
info.path = path;
|
info.path = path;
|
||||||
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
|
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<Node *> to_add;
|
||||||
|
for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
|
||||||
|
AutoLoadInfo &info = E->get();
|
||||||
|
|
||||||
|
info.node = _create_autoload(info.path);
|
||||||
|
|
||||||
if (info.node) {
|
if (info.node) {
|
||||||
Ref<Script> scr = info.node->get_script();
|
Ref<Script> scr = info.node->get_script();
|
||||||
info.in_editor = scr.is_valid() && scr->is_tool();
|
info.in_editor = scr.is_valid() && scr->is_tool();
|
||||||
info.node->set_name(info.name);
|
info.node->set_name(info.name);
|
||||||
|
if (info.in_editor) {
|
||||||
|
to_add.push_back(info.node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.is_singleton) {
|
if (info.is_singleton) {
|
||||||
|
@ -760,8 +778,10 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
||||||
memdelete(info.node);
|
memdelete(info.node);
|
||||||
info.node = NULL;
|
info.node = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
autoload_cache.push_back(info);
|
for (List<Node *>::Element *E = to_add.front(); E; E = E->next()) {
|
||||||
|
get_tree()->get_root()->add_child(E->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload_changed = "autoload_changed";
|
autoload_changed = "autoload_changed";
|
||||||
|
|
Loading…
Reference in a new issue