Преглед на файлове

Print Warning When Using Legacy Asset IDs (#17863)

* Merging Carbonated engine asset catalog legacy asset deprecation warning

Signed-off-by: AMZN-Gene <[email protected]>

* Update Code/Framework/AzFramework/AzFramework/Asset/AssetCatalog.cpp

Co-authored-by: Michael Pollind <[email protected]>
Signed-off-by: Gene Walters <[email protected]>

* Stricter legacy asset warnings; an asset may just have failed to compile. Finding a legacy asset mapping doesn't mean the asset is a legacy asset.

Signed-off-by: AMZN-Gene <[email protected]>

---------

Signed-off-by: AMZN-Gene <[email protected]>
Signed-off-by: Gene Walters <[email protected]>
Co-authored-by: Michael Pollind <[email protected]>
Gene Walters преди 1 година
родител
ревизия
e7da962dff

+ 24 - 2
Code/Framework/AzFramework/AzFramework/Asset/AssetCatalog.cpp

@@ -189,7 +189,18 @@ namespace AzFramework
         AZ::Data::AssetId legacyMapping = m_registry->GetAssetIdByLegacyAssetId(id);
         if (legacyMapping.IsValid())
         {
-            return GetAssetPathByIdInternal(legacyMapping);
+            const AZStd::string legacyAssetPath = GetAssetPathByIdInternal(legacyMapping);
+            AZ_Warning(
+                "O3DE_DEPRECATION_NOTICE(GHI-17861)",
+                legacyAssetPath.empty(),
+                "Deprecated asset id warning! GetAssetPathByIdInternal could not find the modern asset id for \"%s\" and so fell back to using "
+                "the legacy asset id \"%s\"."
+                "Please recreate the asset and update any other assets referencing this asset in order to generate a modern asset id.",
+                legacyAssetPath.c_str(),
+                legacyMapping.ToFixedString().c_str()
+            );
+
+            return legacyAssetPath;
         }
 
         return AZStd::string();
@@ -225,7 +236,18 @@ namespace AzFramework
         AZ::Data::AssetId legacyMapping = m_registry->GetAssetIdByLegacyAssetId(id);
         if (legacyMapping.IsValid())
         {
-            return GetAssetInfoByIdInternal(legacyMapping);
+            const AZ::Data::AssetInfo legacyAssetInfo = GetAssetInfoByIdInternal(legacyMapping);
+            AZ_Warning(
+                "O3DE_DEPRECATION_NOTICE(GHI-17861)",
+                legacyAssetInfo.m_assetType == AZ::Data::s_invalidAssetType,
+                "Deprecated asset id warning! GetAssetInfoByIdInternal could not the modern asset id for \"%s\" and so fell back to using "
+                "the legacy asset id \"%s\"."
+                "Please recreate the asset and update any other assets referencing this asset in order to generate a modern asset id.",
+                legacyAssetInfo.m_relativePath.c_str(),
+                legacyMapping.ToFixedString().c_str()
+            );
+
+            return legacyAssetInfo;
         }
 
         return AZ::Data::AssetInfo();

+ 5 - 0
Code/Framework/AzFramework/AzFramework/Asset/AssetRegistry.h

@@ -37,7 +37,10 @@ namespace AzFramework
         void RegisterAsset(AZ::Data::AssetId id, const AZ::Data::AssetInfo& assetInfo);
         void UnregisterAsset(AZ::Data::AssetId id);
 
+        // O3DE_DEPRECATION_NOTICE(GHI-17861)
         void RegisterLegacyAssetMapping(const AZ::Data::AssetId& legacyId, const AZ::Data::AssetId& newId);
+
+        // O3DE_DEPRECATION_NOTICE(GHI-17861)
         void UnregisterLegacyAssetMappingsForAsset(const AZ::Data::AssetId& id);
 
         void SetAssetDependencies(const AZ::Data::AssetId& id, const AZStd::vector<AZ::Data::ProductDependency>& dependencies);
@@ -55,9 +58,11 @@ namespace AzFramework
 
         void Clear();
 
+        // O3DE_DEPRECATION_NOTICE(GHI-17861)
         // see if the asset ID has been remapped to a new Id:
         AZ::Data::AssetId GetAssetIdByLegacyAssetId(const AZ::Data::AssetId& legacyAssetId) const;
 
+        // O3DE_DEPRECATION_NOTICE(GHI-17861)
         using LegacyAssetIdToRealAssetIdMap = AZStd::unordered_map<AZ::Data::AssetId, AZ::Data::AssetId>;
         LegacyAssetIdToRealAssetIdMap GetLegacyMappingSubsetFromRealIds(const AZStd::vector<AZ::Data::AssetId>& realIds) const;
 

+ 11 - 1
Code/Tools/AssetProcessor/native/AssetManager/AssetCatalog.cpp

@@ -1714,7 +1714,17 @@ namespace AssetProcessor
         AssetId legacyMapping = registryToUse.GetAssetIdByLegacyAssetId(assetId);
         if (legacyMapping.IsValid())
         {
-            return GetProductAssetInfo(platformName, legacyMapping);
+            AZ::Data::AssetInfo legacyAssetInfo = GetProductAssetInfo(platformName, legacyMapping);
+            AZ_Error(
+                "O3DE_DEPRECATION_NOTICE(GHI-17861)",
+                legacyAssetInfo.m_assetType == AZ::Data::s_invalidAssetType,
+                "Deprecated asset id warning! GetProductAssetInfo could not find asset id \"%s\" and so fell back to using the legacy "
+                "asset id. \"%s\". Please look up these asset ids in AssetProcessor and recreate the asset in order to generate a new "
+                "asset id.",
+                assetId.ToFixedString().c_str(),
+                legacyMapping.ToFixedString().c_str());
+
+            return legacyAssetInfo;
         }
 
         return AssetInfo(); // not found!