Allowing prebas with missing components to load, and clarifying error message

Signed-off-by: Mikhail Naumov <mnaumov@amazon.com>
This commit is contained in:
Mikhail Naumov
2021-08-20 18:10:30 -07:00
parent 078e0a8693
commit 875918deda
3 changed files with 32 additions and 4 deletions
@@ -81,9 +81,14 @@ namespace AZ
azrtti_typeid<decltype(componentMap)>(),
inputValue, "Components", context);
static TypeId genericComponentWrapperTypeId("{68D358CA-89B9-4730-8BA6-E181DEA28FDE}");
for (auto& [componentKey, component] : componentMap)
{
entityInstance->m_components.emplace_back(component);
// if underlying type is genericComponentWrapperTypeId, the template is null and the component should not be addded
if (component->GetUnderlyingComponentType() != genericComponentWrapperTypeId)
{
entityInstance->m_components.emplace_back(component);
}
}
result.Combine(componentLoadResult);
@@ -571,9 +571,23 @@ namespace AZ
if (loadedTypeId.m_determination == TypeIdDetermination::FailedToDetermine ||
loadedTypeId.m_determination == TypeIdDetermination::FailedDueToMultipleTypeIds)
{
AZStd::string_view message = loadedTypeId.m_determination == TypeIdDetermination::FailedDueToMultipleTypeIds ?
"Unable to resolve provided type because the same name points to multiple types." :
"Unable to resolve provided type.";
AZStd::string message;
if (loadedTypeId.m_determination == TypeIdDetermination::FailedDueToMultipleTypeIds)
{
message = "Unable to resolve provided type because the same name points to multiple types.";
}
else
{
auto typeField = pointerData.FindMember(JsonSerialization::TypeIdFieldIdentifier);
if (typeField != pointerData.MemberEnd() && typeField->value.IsString())
{
message = AZStd::string::format("Unable to resolve provided type: %s.", typeField->value.GetString());
}
else
{
message = "Unable to resolve provided type.";
}
}
status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown, message);
return ResolvePointerResult::FullyProcessed;
}
@@ -253,6 +253,15 @@ namespace AzToolsFramework
settings.m_metadata.Add(&entityIdMapper);
settings.m_metadata.Create<InstanceEntityScrubber>(newlyAddedEntities);
AZStd::string scratchBuffer;
auto issueReportingCallback = [&scratchBuffer](
AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result,
AZStd::string_view path) -> AZ::JsonSerializationResult::ResultCode
{
return Internal::JsonIssueReporter(scratchBuffer, message, result, path);
};
settings.m_reporting = AZStd::move(issueReportingCallback);
AZ::JsonSerializationResult::ResultCode result = AZ::JsonSerialization::Load(instance, prefabDom, settings);
AZ::Data::AssetManager::Instance().ResumeAssetRelease();