Fire OnEditorEntityCreated notification in SandboxIntegrationManager::CreateNewEntityAtPosition (#7079)
* Ensure to fire OnEditorEntityCreated notification in SandboxIntegrationManager::CreateNewEntityAtPosition Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Ensure to fire OnEditorEntityCreated notification in SandboxIntegrationManager::CreateNewEntityAtPosition Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * convert test AreaNodes_DependentComponentsAdded to use prefab system Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Prevent SetupEditorEntity being called twice Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ def AreaNodes_DependentComponentsAdded():
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
helper.open_level("", "Base")
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
|
||||
+7
-3
@@ -12,6 +12,13 @@ import ly_test_tools.environment.file_system as file_system
|
||||
import ly_test_tools._internal.pytest_plugin as internal_plugin
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomationWithPrefabSystemEnabled(EditorTestSuite):
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_DependentComponentsAdded(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_DependentComponentsAdded as test_module
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@@ -26,9 +33,6 @@ class TestAutomation(EditorTestSuite):
|
||||
class test_LandscapeCanvas_GradientMixer_NodeConstruction(EditorSharedTest):
|
||||
from .EditorScripts import GradientMixer_NodeConstruction as test_module
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_DependentComponentsAdded(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_DependentComponentsAdded as test_module
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_EntityCreatedOnNodeAdd(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_EntityCreatedOnNodeAdd as test_module
|
||||
|
||||
|
||||
@@ -63,9 +63,12 @@ namespace AzToolsFramework
|
||||
/// Registers an existing set of entities with the editor context.
|
||||
virtual void AddEditorEntities(const EntityList& entities) = 0;
|
||||
|
||||
/// Registers an existing set of entities with the editor context.
|
||||
/// Triggers registered callbacks for an existing set of entities with the editor context.
|
||||
virtual void HandleEntitiesAdded(const EntityList& entities) = 0;
|
||||
|
||||
/// Creates an editor ready entity, and sends out notification for the creation.
|
||||
virtual void FinalizeEditorEntity(AZ::Entity* entity) = 0;
|
||||
|
||||
/// Destroys an entity in the editor context.
|
||||
/// \return whether or not the entity was destroyed. A false return value signifies the entity did not belong to the game context.
|
||||
virtual bool DestroyEditorEntity(AZ::EntityId entityId) = 0;
|
||||
|
||||
+6
-17
@@ -227,14 +227,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ::Entity* entity = CreateEntity(name);
|
||||
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());
|
||||
}
|
||||
FinalizeEditorEntity(entity);
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
@@ -263,14 +257,7 @@ namespace AzToolsFramework
|
||||
entity = aznew AZ::Entity(entityId, name);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
AddEntity(entity);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
FinalizeEditorEntity(entity);
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
@@ -284,10 +271,12 @@ namespace AzToolsFramework
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetupEditorEntity(entity);
|
||||
|
||||
// Store creation undo command.
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
SetupEditorEntity(entity);
|
||||
|
||||
ScopedUndoBatch undoBatch("Create Entity");
|
||||
|
||||
EntityCreateCommand* command = aznew EntityCreateCommand(static_cast<AZ::u64>(entity->GetId()));
|
||||
|
||||
+1
-4
@@ -81,6 +81,7 @@ namespace AzToolsFramework
|
||||
void AddEditorEntity(AZ::Entity* entity) override;
|
||||
void AddEditorEntities(const EntityList& entities) override;
|
||||
void HandleEntitiesAdded(const EntityList& entities) override;
|
||||
void FinalizeEditorEntity(AZ::Entity* entity) override;
|
||||
bool CloneEditorEntities(const EntityIdList& sourceEntities,
|
||||
EntityList& resultEntities,
|
||||
AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap) override;
|
||||
@@ -142,13 +143,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnContextEntitiesAdded(const EntityList& entities) override;
|
||||
void OnContextEntityRemoved(const AZ::EntityId& id) override;
|
||||
|
||||
// Helper function for creating editor ready entities.
|
||||
void FinalizeEditorEntity(AZ::Entity* entity);
|
||||
|
||||
void SetupEditorEntity(AZ::Entity* entity);
|
||||
void SetupEditorEntities(const EntityList& entities);
|
||||
|
||||
|
||||
@@ -661,6 +661,7 @@ namespace AzToolsFramework
|
||||
entityOwningInstance.AddEntity(*entity, entityAlias);
|
||||
|
||||
EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequestBus::Events::HandleEntitiesAdded, EntityList{entity});
|
||||
EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequestBus::Events::FinalizeEditorEntity, entity);
|
||||
|
||||
AZ::Transform transform = AZ::Transform::CreateIdentity();
|
||||
transform.SetTranslation(position);
|
||||
|
||||
Reference in New Issue
Block a user