From 94919fe270b0332cb9323b27ba8f4a4bb62ebc0e Mon Sep 17 00:00:00 2001 From: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com> Date: Thu, 27 Jan 2022 09:47:12 -0800 Subject: [PATCH] Moved Serialize Context retrieval out of a loop and expanded an error message in InMemorySpawnableAssetContainer::LoadReferencedAssets. Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com> --- .../Spawnable/InMemorySpawnableAssetContainer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/InMemorySpawnableAssetContainer.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/InMemorySpawnableAssetContainer.cpp index f0fbd1a299..fa7bebfaea 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/InMemorySpawnableAssetContainer.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/InMemorySpawnableAssetContainer.cpp @@ -219,13 +219,12 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils // 2. Gets the exact asset to load to avoid issues with assets that don't reload. AZStd::vector*> blockingAssets; + AZ::SerializeContext* sc = nullptr; + AZ::ComponentApplicationBus::BroadcastResult(sc, &AZ::ComponentApplicationBus::Events::GetSerializeContext); + AZ_Assert(sc, "Unable to locate Serialize Context while resolving asset references in the in-memory spawnable asset container."); + for (AZ::Data::Asset& asset : spawnable.m_assets) { - AZ::SerializeContext* sc = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(sc, &AZ::ComponentApplicationBus::Events::GetSerializeContext); - AZ_Assert( - sc, "Unable to locate Serialize Context while resolving asset references in the in-memory spawnable asset container."); - auto callback = [&blockingAssets]( void* object, const AZ::SerializeContext::ClassData* classData, [[maybe_unused]]const AZ::SerializeContext::ClassElement* elementData) -> bool @@ -236,7 +235,10 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils if (!asset->GetId().IsValid()) { - AZ_Error("Prefab", false, "Invalid asset found referenced in scene while entering game mode"); + AZ_Error( + "Prefab", false, + "Invalid asset found referenced in scene while entering game mode. The asset was stored in an instance of %s.", + classData->m_name); return false; }