summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/import/resource_importer_scene.cpp11
-rw-r--r--editor/script_editor_debugger.cpp2
2 files changed, 12 insertions, 1 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5ac7bc3bc8..5da731b0a0 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1291,6 +1291,13 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
String root_type = p_options["nodes/root_type"];
+ root_type = root_type.split(" ")[0]; // full root_type is "ClassName (filename.gd)" for a script global class.
+
+ Ref<Script> root_script = NULL;
+ if (ScriptServer::is_global_class(root_type)) {
+ root_script = ResourceLoader::load(ScriptServer::get_global_class_path(root_type));
+ root_type = ScriptServer::get_global_class_base(root_type);
+ }
if (root_type != "Spatial") {
Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
@@ -1303,6 +1310,10 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
}
+ if (root_script.is_valid()) {
+ scene->set_script(Variant(root_script));
+ }
+
if (Object::cast_to<Spatial>(scene)) {
float root_scale = p_options["nodes/root_scale"];
Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index a661c2cfc3..621ab039f4 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -262,7 +262,7 @@ void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
return;
ObjectID id = item->get_metadata(0);
- if (item->is_collapsed()) {
+ if (unfold_cache.has(id)) {
unfold_cache.erase(id);
} else {
unfold_cache.insert(id);