From b708bc2c1070ee6fdb18e6ec0b2e62b07e1b3311 Mon Sep 17 00:00:00 2001 From: hultonha Date: Wed, 5 May 2021 16:08:38 +0100 Subject: [PATCH] potential fix for level loading hangs with White Box Component and Atom --- .../Rendering/Atom/WhiteBoxAtomRenderMesh.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp index 9aa29cb288..8ceb95e3a7 100644 --- a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp +++ b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp @@ -119,9 +119,16 @@ namespace WhiteBox modelLodCreator.BeginMesh(); modelLodCreator.SetMeshAabb(meshData.GetAabb()); - // set the default material - auto materialAsset = - AZ::RPI::AssetUtils::LoadAssetByProductPath(TexturedMaterialPath.data()); + const AZ::Data::AssetId materialAssetId = + AZ::RPI::AssetUtils::GetAssetIdForProductPath(TexturedMaterialPath.data(), AZ::RPI::AssetUtils::TraceLevel::Warning); + + auto materialAsset = AZ::Data::AssetManager::Instance().FindAsset(materialAssetId, AZ::Data::AssetLoadBehavior::Default); + if (!materialAsset) + { + // set the default material + materialAsset = AZ::RPI::AssetUtils::LoadAssetById(materialAssetId); + } + if (materialAsset) { modelLodCreator.SetMeshMaterialAsset(materialAsset);