Add support to export nested container entities. Resolves missing parents in spawnables
This commit is contained in:
@@ -187,13 +187,14 @@ namespace AzToolsFramework
|
|||||||
return removedEntity;
|
return removedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::DetachNestedEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback)
|
void Instance::DetachAllEntitiesInHierarchy(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback)
|
||||||
{
|
{
|
||||||
|
callback(AZStd::move(DetachContainerEntity()));
|
||||||
DetachEntities(callback);
|
DetachEntities(callback);
|
||||||
|
|
||||||
for (const auto& [instanceAlias, instance] : m_nestedInstances)
|
for (const auto& [instanceAlias, instance] : m_nestedInstances)
|
||||||
{
|
{
|
||||||
instance->DetachNestedEntities(callback);
|
instance->DetachAllEntitiesInHierarchy(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,14 @@ namespace AzToolsFramework
|
|||||||
bool AddEntity(AZ::Entity& entity, EntityAlias entityAlias);
|
bool AddEntity(AZ::Entity& entity, EntityAlias entityAlias);
|
||||||
AZStd::unique_ptr<AZ::Entity> DetachEntity(const AZ::EntityId& entityId);
|
AZStd::unique_ptr<AZ::Entity> DetachEntity(const AZ::EntityId& entityId);
|
||||||
void DetachEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
void DetachEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
||||||
void DetachNestedEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
|
||||||
|
/**
|
||||||
|
* Detaches all entities in the instance hierarchy, including; all direct and nested entities, all container entities.
|
||||||
|
* Note that without container entities the hierarchy that remains cannot be used further without restoring new ones
|
||||||
|
* @param callback A user provided callback that can be used to capture ownership and manipulate the detached entities.
|
||||||
|
*/
|
||||||
|
void DetachAllEntitiesInHierarchy(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
||||||
|
|
||||||
void RemoveNestedEntities(const AZStd::function<bool(const AZStd::unique_ptr<AZ::Entity>&)>& filter);
|
void RemoveNestedEntities(const AZStd::function<bool(const AZStd::unique_ptr<AZ::Entity>&)>& filter);
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|||||||
+1
-5
@@ -38,11 +38,7 @@ namespace AzToolsFramework::Prefab::SpawnableUtils
|
|||||||
// going to be used to create clones of the entities.
|
// going to be used to create clones of the entities.
|
||||||
{
|
{
|
||||||
AzFramework::Spawnable::EntityList& entities = spawnable.GetEntities();
|
AzFramework::Spawnable::EntityList& entities = spawnable.GetEntities();
|
||||||
if (instance.HasContainerEntity())
|
instance.DetachAllEntitiesInHierarchy(
|
||||||
{
|
|
||||||
entities.emplace_back(AZStd::move(instance.DetachContainerEntity()));
|
|
||||||
}
|
|
||||||
instance.DetachNestedEntities(
|
|
||||||
[&entities](AZStd::unique_ptr<AZ::Entity> entity)
|
[&entities](AZStd::unique_ptr<AZ::Entity> entity)
|
||||||
{
|
{
|
||||||
entities.emplace_back(AZStd::move(entity));
|
entities.emplace_back(AZStd::move(entity));
|
||||||
|
|||||||
Reference in New Issue
Block a user