Fixed a sync issue when a PrefaDOM was taken from a PrefabDocument.

When a PrefabDOM was taken from a PrefabDocument the Instance would continue to have the data from the original Prefab, which means they'd no longer be in sync as the Prefab would be empty. This was fixed by resetting the Instance so they're both clear.

Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
monroegm-disable-blank-issue-2
AMZN-koppersr 4 years ago
parent 13375cd7d9
commit e2a960e442

@ -16,7 +16,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
: m_name(AZStd::move(name))
, m_instance(AZStd::make_unique<AzToolsFramework::Prefab::Instance>())
{
m_instance->SetTemplateSourcePath(AZ::IO::Path("InMemory") / name);
m_instance->SetTemplateSourcePath(AZ::IO::Path("InMemory") / m_name);
}
bool PrefabDocument::SetPrefabDom(const PrefabDom& prefab)
@ -64,8 +64,14 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
{
if (m_isDirty)
{
m_isDirty = !PrefabDomUtils::StoreInstanceInPrefabDom(*m_instance, m_dom);
[[maybe_unused]] bool storedSuccessfully = PrefabDomUtils::StoreInstanceInPrefabDom(*m_instance, m_dom);
AZ_Assert(storedSuccessfully, "Failed to store Instance '%s' to PrefabDom.", m_name.c_str());
m_isDirty = false;
}
// After the PrefabDom is moved an empty PrefabDom is left behind. This should be reflected in the Instance,
// so reset it so it's empty as well.
m_instance->Reset();
m_instance->SetTemplateSourcePath(AZ::IO::Path("InMemory") / m_name);
return AZStd::move(m_dom);
}

@ -245,7 +245,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
AZ::Data::Asset<AzFramework::Spawnable>(target->m_spawnable.GetId(), azrtti_typeid<AzFramework::Spawnable>()), alias.m_tag,
sourceIndex, targetIndex,
alias.m_aliasType, alias.m_loadBehavior == EntityAliasSpawnableLoadBehavior::QueueLoad);
// Register the dependency between the two spawnables.
RegisterProductAssetDependency(source->m_spawnable.GetId(), target->m_spawnable.GetId(), loadBehavior);

Loading…
Cancel
Save