From 55b4b30ab29a85e4af7c2f10494cfdd0e7bccc46 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 22 May 2018 13:26:13 -0300 Subject: [PATCH] Only add autoloads in editor if they have tool scripts --- editor/editor_autoload_settings.cpp | 209 +++++++++++++++++----------- editor/editor_autoload_settings.h | 10 ++ main/main.cpp | 25 +--- 3 files changed, 136 insertions(+), 108 deletions(-) diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 708bff252a4..de9203232ca 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -52,6 +52,13 @@ void EditorAutoloadSettings::_notification(int p_what) { file_dialog->add_filter("*." + E->get()); } + + for (List::Element *E = autoload_cache.front(); E; E = E->next()) { + AutoLoadInfo &info = E->get(); + if (info.node && info.in_editor) { + get_tree()->get_root()->call_deferred("add_child", info.node); + } + } } } @@ -291,6 +298,36 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { autoload_add_name->set_text(p_path.get_file().get_basename()); } +Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { + RES res = ResourceLoader::load(p_path); + ERR_EXPLAIN("Can't autoload: " + p_path); + ERR_FAIL_COND_V(res.is_null(), NULL); + Node *n = NULL; + if (res->is_class("PackedScene")) { + Ref ps = res; + n = ps->instance(); + } else if (res->is_class("Script")) { + Ref