Fixed a MaterialBuilder issue where material version updates were incorrectly reporting failure in some cases.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -64,10 +64,16 @@ namespace AZ
|
||||
|
||||
PropertyGroupMap m_properties;
|
||||
|
||||
enum class ApplyVersionUpdatesResult
|
||||
{
|
||||
Failed,
|
||||
NoUpdates,
|
||||
UpdatesApplied
|
||||
};
|
||||
|
||||
//! Checks the material type version and potentially applies a series of property changes (most common are simple property renames)
|
||||
//! based on the MaterialTypeAsset's version update procedure.
|
||||
//! @return true if any changes were applied
|
||||
bool ApplyVersionUpdates();
|
||||
ApplyVersionUpdatesResult ApplyVersionUpdates(AZStd::string_view materialSourceFilePath);
|
||||
|
||||
//! Creates a MaterialAsset from the MaterialSourceData content.
|
||||
//! @param assetId ID for the MaterialAsset
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace AZ
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!material.GetValue().ApplyVersionUpdates())
|
||||
if (MaterialSourceData::ApplyVersionUpdatesResult::Failed == material.GetValue().ApplyVersionUpdates(materialSourceFilePath))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -73,19 +73,20 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialSourceData::ApplyVersionUpdates()
|
||||
MaterialSourceData::ApplyVersionUpdatesResult MaterialSourceData::ApplyVersionUpdates(AZStd::string_view materialSourceFilePath)
|
||||
{
|
||||
auto materialTypeSourceDataOutcome = MaterialUtils::LoadMaterialTypeSourceData(m_materialType);
|
||||
AZStd::string materialTypeFullPath = AssetUtils::ResolvePathReference(materialSourceFilePath, m_materialType);
|
||||
auto materialTypeSourceDataOutcome = MaterialUtils::LoadMaterialTypeSourceData(materialTypeFullPath);
|
||||
if (!materialTypeSourceDataOutcome.IsSuccess())
|
||||
{
|
||||
return false;
|
||||
return ApplyVersionUpdatesResult::Failed;
|
||||
}
|
||||
|
||||
MaterialTypeSourceData materialTypeSourceData = materialTypeSourceDataOutcome.TakeValue();
|
||||
|
||||
if (m_materialTypeVersion == materialTypeSourceData.m_version)
|
||||
{
|
||||
return false;
|
||||
return ApplyVersionUpdatesResult::NoUpdates;
|
||||
}
|
||||
|
||||
bool changesWereApplied = false;
|
||||
@@ -125,7 +126,7 @@ namespace AZ
|
||||
|
||||
m_materialTypeVersion = materialTypeSourceData.m_version;
|
||||
|
||||
return true;
|
||||
return changesWereApplied ? ApplyVersionUpdatesResult::UpdatesApplied : ApplyVersionUpdatesResult::NoUpdates;
|
||||
}
|
||||
|
||||
Outcome<Data::Asset<MaterialAsset> > MaterialSourceData::CreateMaterialAsset(Data::AssetId assetId, AZStd::string_view materialSourceFilePath, bool elevateWarnings, bool includeMaterialPropertyNames) const
|
||||
|
||||
Reference in New Issue
Block a user