Reports warnings when a material version auto update is applied, notifying the user they should update their source data.

Also improved the MaterialAssetTests UpgradeMaterialAsset() to focus on testing the inputs and outputs of the class rather than the private internal data.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2021-10-20 23:36:53 -07:00
parent 836d018de7
commit 1633ced656
7 changed files with 103 additions and 22 deletions
@@ -80,9 +80,16 @@ namespace AZ
{
return false;
}
MaterialTypeSourceData materialTypeSourceData = materialTypeSourceDataOutcome.TakeValue();
if (m_materialTypeVersion == materialTypeSourceData.m_version)
{
return false;
}
bool changesWereApplied = false;
// Note that the only kind of property update currently supported is rename...
for (auto& groupPair : m_properties)
@@ -97,6 +104,7 @@ namespace AZ
if (materialTypeSourceData.ApplyPropertyRenames(propertyId, m_materialTypeVersion))
{
newPropertyMap[propertyId.GetPropertyName().GetStringView()] = propertyPair.second;
changesWereApplied = true;
}
else
{
@@ -107,8 +115,16 @@ namespace AZ
propertyMap = newPropertyMap;
}
m_materialTypeVersion = materialTypeSourceData.m_version;
if (changesWereApplied)
{
AZ_Warning("MaterialSourceData", false,
"This material is based on version %u of '%s', but the material type is now at version %u. "
"Automatic updates are available. Consider updating the .material source file.",
m_materialTypeVersion, m_materialType.c_str(), materialTypeSourceData.m_version);
}
m_materialTypeVersion = materialTypeSourceData.m_version;
return true;
}