Merge pull request #3256 from aws-lumberyard-dev/mnaumov/2372_signOffFix
Fixing a crash when unparenting prefab instance in a new level
This commit is contained in:
+10
@@ -15,6 +15,7 @@
|
|||||||
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
|
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
|
||||||
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
|
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
|
||||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||||
|
#include <Prefab/PrefabDomUtils.h>
|
||||||
|
|
||||||
namespace AzToolsFramework
|
namespace AzToolsFramework
|
||||||
{
|
{
|
||||||
@@ -81,6 +82,15 @@ namespace AzToolsFramework
|
|||||||
result.Combine(resultInstances);
|
result.Combine(resultInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrefabDomUtils::LinkIdMetadata* subPathLinkId = context.GetMetadata().Find<PrefabDomUtils::LinkIdMetadata>();
|
||||||
|
if (subPathLinkId)
|
||||||
|
{
|
||||||
|
AZ::ScopedContextPath subPathSource(context, "m_linkId");
|
||||||
|
|
||||||
|
result = ContinueStoringToJsonObjectField(
|
||||||
|
outputValue, "LinkId", &(instance->m_linkId), &InvalidLinkId, azrtti_typeid<decltype(instance->m_linkId)>(), context);
|
||||||
|
}
|
||||||
|
|
||||||
return context.Report(result,
|
return context.Report(result,
|
||||||
result.GetProcessing() == JSR::Processing::Completed ? "Successfully stored Instance information for Prefab." :
|
result.GetProcessing() == JSR::Processing::Completed ? "Successfully stored Instance information for Prefab." :
|
||||||
"Failed to store Instance information for Prefab.");
|
"Failed to store Instance information for Prefab.");
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ namespace AzToolsFramework
|
|||||||
settings.m_keepDefaults = true;
|
settings.m_keepDefaults = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & StoreFlags::StoreLinkIds) != StoreFlags::None)
|
||||||
|
{
|
||||||
|
settings.m_metadata.Create<LinkIdMetadata>();
|
||||||
|
}
|
||||||
|
|
||||||
AZStd::string scratchBuffer;
|
AZStd::string scratchBuffer;
|
||||||
auto issueReportingCallback = [&scratchBuffer]
|
auto issueReportingCallback = [&scratchBuffer]
|
||||||
(AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result,
|
(AZStd::string_view message, AZ::JsonSerializationResult::ResultCode result,
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ namespace AzToolsFramework
|
|||||||
|
|
||||||
//! By default an instance will be stored with default values. In cases where we want to store less json without defaults
|
//! By default an instance will be stored with default values. In cases where we want to store less json without defaults
|
||||||
//! such as saving to disk, this flag will control that behavior.
|
//! such as saving to disk, this flag will control that behavior.
|
||||||
StripDefaultValues = 1 << 0
|
StripDefaultValues = 1 << 0,
|
||||||
|
|
||||||
|
//! We do not save linkIds to file. However when loading a level we want to temporarily save
|
||||||
|
//! linkIds to instance dom so any nested prefabs will have linkIds correctly set.
|
||||||
|
StoreLinkIds = 1 << 1
|
||||||
};
|
};
|
||||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(StoreFlags);
|
AZ_DEFINE_ENUM_BITWISE_OPERATORS(StoreFlags);
|
||||||
|
|
||||||
@@ -150,6 +154,14 @@ namespace AzToolsFramework
|
|||||||
[[maybe_unused]] const AZStd::string_view printMessage,
|
[[maybe_unused]] const AZStd::string_view printMessage,
|
||||||
[[maybe_unused]] const AzToolsFramework::Prefab::PrefabDomValue& prefabDomValue);
|
[[maybe_unused]] const AzToolsFramework::Prefab::PrefabDomValue& prefabDomValue);
|
||||||
|
|
||||||
|
//! An empty struct for passing to JsonSerializerSettings.m_metadata that is consumed by InstanceSerializer::Store.
|
||||||
|
//! If present in metadata, linkIds will be stored to instance dom.
|
||||||
|
struct LinkIdMetadata
|
||||||
|
{
|
||||||
|
AZ_RTTI(LinkIdMetadata, "{8FF7D299-14E3-41D4-90C5-393A240FAE7C}");
|
||||||
|
|
||||||
|
virtual ~LinkIdMetadata() {}
|
||||||
|
};
|
||||||
} // namespace PrefabDomUtils
|
} // namespace PrefabDomUtils
|
||||||
} // namespace Prefab
|
} // namespace Prefab
|
||||||
} // namespace AzToolsFramework
|
} // namespace AzToolsFramework
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ namespace AzToolsFramework
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrefabDom storedPrefabDom(&loadedTemplateDom->get().GetAllocator());
|
PrefabDom storedPrefabDom(&loadedTemplateDom->get().GetAllocator());
|
||||||
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom))
|
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom, PrefabDomUtils::StoreFlags::StoreLinkIds))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user