diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-11-20 09:13:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 09:13:36 +0100 |
commit | 91349290dce955abe8c8014e9107d1a4bd35ae9c (patch) | |
tree | da5bab19bc6bc231649a63e86fbaf7c25f2c8048 /editor/import | |
parent | 3dad0ce8f4815165966751705a07fae6e6e2b796 (diff) | |
parent | 400db80d25d5e19fe68bbd3f04115c1578af7eac (diff) |
Merge pull request #12717 from NathanWarden/material_import_fix
Fixed a bug where materials and/or meshes weren't assigned to scene on first import.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index cbc21c9536..63d4039295 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -907,12 +907,11 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material"); if (p_keep_materials && FileAccess::exists(ext_name)) { //if exists, use it - Ref<Material> existing = ResourceLoader::load(ext_name); - p_materials[mat] = existing; + p_materials[mat] = ResourceLoader::load(ext_name); } else { ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH); - p_materials[mat] = mat; + p_materials[mat] = ResourceLoader::load(ext_name); } } @@ -936,7 +935,8 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String String ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH); - p_meshes[mesh] = mesh; + p_meshes[mesh] = ResourceLoader::load(ext_name); + p_node->set(E->get().name, p_meshes[mesh]); mesh_just_added = true; } } @@ -956,18 +956,24 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String ; if (FileAccess::exists(ext_name)) { //if exists, use it - Ref<Material> existing = ResourceLoader::load(ext_name); - p_materials[mat] = existing; + p_materials[mat] = ResourceLoader::load(ext_name); } else { ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH); - p_materials[mat] = mat; + p_materials[mat] = ResourceLoader::load(ext_name); } } if (p_materials[mat] != mat) { mesh->surface_set_material(i, p_materials[mat]); + + //re-save the mesh since a material is now assigned + if (p_make_meshes) { + String ext_name = p_base_path.plus_file(_make_extname(mesh->get_name()) + ".mesh"); + ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH); + p_meshes[mesh] = ResourceLoader::load(ext_name); + } } } |