diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-05-29 17:31:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 17:31:15 +0200 |
commit | c51d2ed55cad49e9f5928194b480e5a58bc058ce (patch) | |
tree | ca5b1f1b588ead77c6ddb3315a87ef1d5a55bd5c /editor | |
parent | 23a9ba68e6773b30b8761eccbb257726fa9fb916 (diff) | |
parent | c478f3032112157865815c5ad892427b8d0fb531 (diff) |
Merge pull request #25480 from WindyDarian/scene_import_root_type_script_global_class_support
Support script global class (class_name) as root_type when importing a scene
Diffstat (limited to 'editor')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 11 |
1 files changed, 11 insertions, 0 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)); |