Fix undo for create editor entity (#6785)
* Avoid undoing twice when undo is hit for CreateNewEditorEntity Signed-off-by: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com> * Moved an assert immediately after entity creation Signed-off-by: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com>
This commit is contained in:
+18
-2
@@ -226,7 +226,15 @@ namespace AzToolsFramework
|
||||
AZ::EntityId EditorEntityContextComponent::CreateNewEditorEntity(const char* name)
|
||||
{
|
||||
AZ::Entity* entity = CreateEntity(name);
|
||||
FinalizeEditorEntity(entity);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
@@ -253,8 +261,16 @@ namespace AzToolsFramework
|
||||
return AZ::EntityId();
|
||||
}
|
||||
entity = aznew AZ::Entity(entityId, name);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
AddEntity(entity);
|
||||
FinalizeEditorEntity(entity);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user