material editor and exporter save source materials with relative paths
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
@@ -300,48 +300,6 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
bool MaterialTypeSourceData::ConvertPropertyValueToSourceDataFormat(const PropertyDefinition& propertyDefinition, MaterialPropertyValue& propertyValue) const
|
||||
{
|
||||
if (propertyDefinition.m_dataType == AZ::RPI::MaterialPropertyDataType::Enum && propertyValue.Is<uint32_t>())
|
||||
{
|
||||
const uint32_t index = propertyValue.GetValue<uint32_t>();
|
||||
if (index >= propertyDefinition.m_enumValues.size())
|
||||
{
|
||||
AZ_Error("Material source data", false, "Invalid value for material enum property: '%s'.", propertyDefinition.m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
propertyValue = propertyDefinition.m_enumValues[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
// Image asset references must be converted from asset IDs to a relative source file path
|
||||
if (propertyDefinition.m_dataType == AZ::RPI::MaterialPropertyDataType::Image && propertyValue.Is<Data::Asset<ImageAsset>>())
|
||||
{
|
||||
const Data::Asset<ImageAsset>& imageAsset = propertyValue.GetValue<Data::Asset<ImageAsset>>();
|
||||
|
||||
Data::AssetInfo imageAssetInfo;
|
||||
if (imageAsset.GetId().IsValid())
|
||||
{
|
||||
bool result = false;
|
||||
AZStd::string rootFilePath;
|
||||
const AZStd::string platformName = ""; // Empty for default
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(result, &AzToolsFramework::AssetSystem::AssetSystemRequest::GetAssetInfoById,
|
||||
imageAsset.GetId(), imageAsset.GetType(), platformName, imageAssetInfo, rootFilePath);
|
||||
if (!result)
|
||||
{
|
||||
AZ_Error("Material source data", false, "Image asset could not be found for property: '%s'.", propertyDefinition.m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
propertyValue = imageAssetInfo.m_relativePath;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Outcome<Data::Asset<MaterialTypeAsset>> MaterialTypeSourceData::CreateMaterialTypeAsset(Data::AssetId assetId, AZStd::string_view materialTypeSourceFilePath, bool elevateWarnings) const
|
||||
{
|
||||
MaterialTypeAssetCreator materialTypeAssetCreator;
|
||||
|
||||
Reference in New Issue
Block a user