Merge pull request #3377 from aws-lumberyard-dev/mnaumov/LYN-4539

Allowing prefabs with missing components to load, and clarifying error message
This commit is contained in:
AMZN-koppersr
2021-08-24 10:42:40 -07:00
committed by GitHub
3 changed files with 32 additions and 6 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,11 +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.";
status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown, message);
return ResolvePointerResult::FullyProcessed;
auto typeField = pointerData.FindMember(JsonSerialization::TypeIdFieldIdentifier);
if (typeField != pointerData.MemberEnd() && typeField->value.IsString())
{
const char* format = loadedTypeId.m_determination == TypeIdDetermination::FailedToDetermine ?
"Unable to resolve provided type: %.*s." :
"Unable to resolve provided type %.*s because the same name points to multiple types.";
status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown,
AZStd::string::format(format, typeField->value.GetStringLength(), typeField->value.GetString()));
}
else
{
const char* message = loadedTypeId.m_determination == TypeIdDetermination::FailedToDetermine ?
"Unable to resolve provided type." :
"Unable to resolve provided type because the same name points to multiple types.";
status = context.Report(Tasks::RetrieveInfo, Outcomes::Unknown, message);
}
return ResolvePointerResult::FullyProcessed;
}
if (loadedTypeId.m_typeId != objectType)
@@ -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();