Reset the prefab root instance before removing the corresponding template (#2287)
* Remove dirty entities correctly when prefab entities get destroyed Signed-off-by: srikappa-amzn <srikappa@amazon.com> * Remove call to clear dirty entity for single entity delete Signed-off-by: srikappa-amzn <srikappa@amazon.com> * Removed couple of asserts because order of operations is not fixed Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
+3
-1
@@ -88,13 +88,15 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (m_rootInstance)
|
||||
{
|
||||
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
|
||||
&AzToolsFramework::ToolsApplicationRequestBus::Events::ClearDirtyEntities);
|
||||
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
|
||||
m_rootInstance->Reset();
|
||||
if (templateId != Prefab::InvalidTemplateId)
|
||||
{
|
||||
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
|
||||
m_prefabSystemComponent->RemoveTemplate(templateId);
|
||||
}
|
||||
m_rootInstance->Reset();
|
||||
m_rootInstance->SetContainerEntityName("Level");
|
||||
}
|
||||
|
||||
|
||||
@@ -82,16 +82,7 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
// If this instance's templateId is valid, we should be able to unregister this instance from
|
||||
// Template to Instance mapping successfully.
|
||||
if (m_templateId != InvalidTemplateId &&
|
||||
!m_templateInstanceMapper->UnregisterInstance(*this))
|
||||
{
|
||||
AZ_Assert(false,
|
||||
"Prefab - Attempted to Unregister Instance from Template with Id '%u'. "
|
||||
"Instance may never have been registered or was unregistered early.",
|
||||
m_templateId);
|
||||
}
|
||||
m_templateInstanceMapper->UnregisterInstance(*this);
|
||||
|
||||
m_templateId = templateId;
|
||||
|
||||
@@ -221,15 +212,7 @@ namespace AzToolsFramework
|
||||
|
||||
void Instance::Reset()
|
||||
{
|
||||
// Clean up Instance associations.
|
||||
if (m_templateId != InvalidTemplateId && !m_templateInstanceMapper->UnregisterInstance(*this))
|
||||
{
|
||||
AZ_Assert(
|
||||
false,
|
||||
"Prefab - Attempted to unregister Instance from Template on file path '%s' with Id '%u'. "
|
||||
"Instance may never have been registered or was unregistered early.",
|
||||
m_templateSourcePath.c_str(), m_templateId);
|
||||
}
|
||||
m_templateInstanceMapper->UnregisterInstance(*this);
|
||||
|
||||
ClearEntities();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user