Prefab saving
This commit is contained in:
24
Nuake/src/Resource/Prefab.cpp
Normal file
24
Nuake/src/Resource/Prefab.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "Prefab.h"
|
||||
#include "src/Scene/Components/ParentComponent.h"
|
||||
|
||||
namespace Nuake {
|
||||
Ref<Prefab> Prefab::CreatePrefabFromEntity(Entity entity)
|
||||
{
|
||||
Ref<Prefab> prefab = CreateRef<Prefab>();
|
||||
ParentComponent parentC = entity.GetComponent<ParentComponent>();
|
||||
prefab->EntityWalker(entity);
|
||||
|
||||
return prefab;
|
||||
}
|
||||
|
||||
void Prefab::EntityWalker(Entity entity)
|
||||
{
|
||||
entity.GetComponent<NameComponent>().IsPrefab = true;
|
||||
Entities.push_back(entity);
|
||||
|
||||
for (const Entity& e : entity.GetComponent<ParentComponent>().Children)
|
||||
{
|
||||
EntityWalker(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user