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.
This commit is contained in:
commit
91349290dc
1 changed files with 13 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue