Add an option to skip existing materials when reimporting.
This commit is contained in:
@@ -374,6 +374,7 @@ void ModelTool::Options::Serialize(SerializeStream& stream, const void* otherObj
|
||||
SERIALIZE(InstanceToImportAs);
|
||||
SERIALIZE(ImportTextures);
|
||||
SERIALIZE(RestoreMaterialsOnReimport);
|
||||
SERIALIZE(SkipExistingMaterialsOnReimport);
|
||||
SERIALIZE(GenerateSDF);
|
||||
SERIALIZE(SDFResolution);
|
||||
SERIALIZE(SplitObjects);
|
||||
@@ -422,6 +423,7 @@ void ModelTool::Options::Deserialize(DeserializeStream& stream, ISerializeModifi
|
||||
DESERIALIZE(InstanceToImportAs);
|
||||
DESERIALIZE(ImportTextures);
|
||||
DESERIALIZE(RestoreMaterialsOnReimport);
|
||||
DESERIALIZE(SkipExistingMaterialsOnReimport);
|
||||
DESERIALIZE(GenerateSDF);
|
||||
DESERIALIZE(SDFResolution);
|
||||
DESERIALIZE(SplitObjects);
|
||||
@@ -1154,6 +1156,18 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip any materials that already exist from the model.
|
||||
// This allows the use of "import as material instances" without material properties getting overridden on each import.
|
||||
if (options.SkipExistingMaterialsOnReimport)
|
||||
{
|
||||
AssetInfo info;
|
||||
if (Content::GetAssetInfo(assetPath, info))
|
||||
{
|
||||
material.AssetID = info.ID;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.ImportMaterialsAsInstances)
|
||||
{
|
||||
// Create material instance
|
||||
|
||||
Reference in New Issue
Block a user