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:
@@ -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