Merge pull request #1705 from aws-lumberyard-dev/Atom/guthadam/ATOM-15908
ATOM-15908 Fixed material component exporter to use correct relative paths
This commit is contained in:
+24
-13
@@ -96,8 +96,11 @@ namespace AZ
|
|||||||
|
|
||||||
bool SaveSourceMaterialFromEditData(const AZStd::string& path, const MaterialEditData& editData)
|
bool SaveSourceMaterialFromEditData(const AZStd::string& path, const MaterialEditData& editData)
|
||||||
{
|
{
|
||||||
// Getting the source info for the material type file to make sure that it exists
|
// Construct the material source data object that will be exported
|
||||||
// We also need to watch folder to generate a relative asset path for the material type
|
AZ::RPI::MaterialSourceData exportData;
|
||||||
|
exportData.m_propertyLayoutVersion = editData.m_materialTypeSourceData.m_propertyLayout.m_version;
|
||||||
|
|
||||||
|
// Converting absolute material paths to relative paths
|
||||||
bool result = false;
|
bool result = false;
|
||||||
AZ::Data::AssetInfo info;
|
AZ::Data::AssetInfo info;
|
||||||
AZStd::string watchFolder;
|
AZStd::string watchFolder;
|
||||||
@@ -106,22 +109,30 @@ namespace AZ
|
|||||||
editData.m_materialTypeSourcePath.c_str(), info, watchFolder);
|
editData.m_materialTypeSourcePath.c_str(), info, watchFolder);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
AZ_Error("AZ::Render::EditorMaterialComponentUtil", false, "Failed to get source file info and asset path while attempting to export: %s", path.c_str());
|
AZ_Error(
|
||||||
|
"AZ::Render::EditorMaterialComponentUtil", false,
|
||||||
|
"Failed to get material type source file info while attempting to export: %s", path.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the material source data object that will be exported
|
exportData.m_materialType = info.m_relativePath;
|
||||||
AZ::RPI::MaterialSourceData exportData;
|
|
||||||
exportData.m_propertyLayoutVersion = editData.m_materialTypeSourceData.m_propertyLayout.m_version;
|
|
||||||
|
|
||||||
// Converting absolute material paths to asset relative paths
|
if (!editData.m_materialParentSourcePath.empty())
|
||||||
exportData.m_materialType = editData.m_materialTypeSourcePath;
|
{
|
||||||
AzFramework::ApplicationRequests::Bus::Broadcast(
|
result = false;
|
||||||
&AzFramework::ApplicationRequests::Bus::Events::MakePathRelative, exportData.m_materialType, watchFolder.c_str());
|
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||||
|
result, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath,
|
||||||
|
editData.m_materialParentSourcePath.c_str(), info, watchFolder);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
AZ_Error(
|
||||||
|
"AZ::Render::EditorMaterialComponentUtil", false,
|
||||||
|
"Failed to get parent material source file info while attempting to export: %s", path.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
exportData.m_parentMaterial = editData.m_materialParentSourcePath;
|
exportData.m_parentMaterial = info.m_relativePath;
|
||||||
AzFramework::ApplicationRequests::Bus::Broadcast(
|
}
|
||||||
&AzFramework::ApplicationRequests::Bus::Events::MakePathRelative, exportData.m_parentMaterial, watchFolder.c_str());
|
|
||||||
|
|
||||||
// Copy all of the properties from the material asset to the source data that will be exported
|
// Copy all of the properties from the material asset to the source data that will be exported
|
||||||
result = true;
|
result = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user