Moved the Material Component property override renaming to EditorMaterialComponent via ApplyAutomaticPropertyUpdates.

MaterialAssignment::ApplyProperties() still reports warnings but does not update the m_propertyOverrides.
MaterialAssignment::ApplyProperties() will now skip the old name'd overrides if overrides are present for the new names. I'm not sure if this will ever happen, but it did happen while I had some intermediate changes, so I imagine it could happen again.
I had to update the Material::FindPropertyIndex function to expose information about renames when they occur. This should make it easier for other systems to get (somewhat) automatic benefit from the version update feature.
I also found that there was an issue with material inspector where it wouldn't be initialized the the right override values when renames were present. Now it applies the renames to whatever override data it gets from the Material Component.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
santorac
2021-10-22 16:41:44 -07:00
parent 43b7bf6ba7
commit 3c331e00ff
9 changed files with 154 additions and 31 deletions
@@ -386,9 +386,39 @@ namespace AZ
return m_currentChangeId;
}
MaterialPropertyIndex Material::FindPropertyIndex(const Name& propertyId) const
MaterialPropertyIndex Material::FindPropertyIndex(const Name& propertyId, bool* wasRenamed, Name* newName) const
{
return m_layout->FindPropertyIndex(propertyId);
if (wasRenamed)
{
*wasRenamed = false;
}
MaterialPropertyIndex index = m_layout->FindPropertyIndex(propertyId);
if (!index.IsValid())
{
Name renamedId = propertyId;
if (m_materialAsset->GetMaterialTypeAsset()->ApplyPropertyRenames(renamedId))
{
index = m_layout->FindPropertyIndex(renamedId);
if (wasRenamed)
{
*wasRenamed = true;
}
if (newName)
{
*newName = renamedId;
}
AZ_Warning("Material", false,
"Material property '%s' has been renamed to '%s'. Consider updating the corresponding source data.",
propertyId.GetCStr(),
renamedId.GetCStr());
}
}
return index;
}
template<typename Type>