Clear prefab templates on new level creations and loads (#2842)

* Clear prefab templates on new level creations and loads

Signed-off-by: srikappa-amzn <srikappa@amazon.com>

* Fixed failing prefab unit tests after change to clear templates

Signed-off-by: srikappa-amzn <srikappa@amazon.com>
monroegm-disable-blank-issue-2
srikappa-amzn 4 years ago committed by GitHub
parent fa3b309c67
commit 7404622b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -72,15 +72,8 @@ namespace AzToolsFramework
if (m_rootInstance != nullptr)
{
// Need to save off the template id to remove the template after the instance is deleted.
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
m_rootInstance.reset();
if (templateId != Prefab::InvalidTemplateId)
{
// Remove the template here so that if we're in a Deactivate/Activate cycle, it can recreate the template/rootInstance
// correctly
m_prefabSystemComponent->RemoveTemplate(templateId);
}
m_prefabSystemComponent->RemoveAllTemplates();
}
}
@ -95,7 +88,7 @@ namespace AzToolsFramework
if (templateId != Prefab::InvalidTemplateId)
{
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
m_prefabSystemComponent->RemoveTemplate(templateId);
m_prefabSystemComponent->RemoveAllTemplates();
}
m_rootInstance->SetContainerEntityName("Level");
}

@ -245,7 +245,9 @@ namespace UnitTest
m_instanceToTemplateInterface->GenerateDomForInstance(instanceDomBeforeUpdate, *firstInstance);
//remove instance from instance
firstInstance->DetachNestedInstance(addedAlias);
AZStd::unique_ptr<Instance> detachedInstance = firstInstance->DetachNestedInstance(addedAlias);
ASSERT_TRUE(detachedInstance != nullptr);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
//create document with after change snapshot
PrefabDom instanceDomAfterUpdate;

@ -309,6 +309,7 @@ namespace UnitTest
// and use the updated enclosing Instance to update the PrefabDom of Template.
AZStd::unique_ptr<Instance> detachedInstance = newEnclosingInstance->DetachNestedInstance(nestedInstanceAliases.front());
ASSERT_TRUE(detachedInstance);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
PrefabDom updatedTemplateDom;
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*newEnclosingInstance, updatedTemplateDom));

@ -274,6 +274,7 @@ namespace UnitTest
InstanceAlias aliasOfWheelInstanceToRetain = wheelInstanceAliasesUnderAxle.front();
AZStd::unique_ptr<Instance> detachedInstance = axleInstance->DetachNestedInstance(wheelInstanceAliasesUnderAxle.back());
ASSERT_TRUE(detachedInstance);
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
PrefabDom updatedAxleInstanceDom;
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*axleInstance, updatedAxleInstanceDom));
m_prefabSystemComponent->UpdatePrefabTemplate(axleTemplateId, updatedAxleInstanceDom);

Loading…
Cancel
Save