add EditorNameComponent by default

This commit is contained in:
SweetId 2023-10-12 19:15:02 -04:00
parent d6ecfb3476
commit 4ec877f656
3 changed files with 7 additions and 3 deletions

View File

@ -37,7 +37,7 @@ namespace Nz
bool CloseLevel();
bool OpenLevel(const std::filesystem::path& path);
entt::handle CreateEntity();
entt::handle CreateEntity(const std::string& name);
template<typename T>
void RegisterWindow()

View File

@ -1,4 +1,5 @@
#include <NazaraEditor/Core/Application/BaseApplication.hpp>
#include <NazaraEditor/Core/Components/NameComponent.hpp>
namespace Nz
{
@ -49,9 +50,12 @@ namespace Nz
return m_level;
}
entt::handle EditorBaseApplication::CreateEntity()
entt::handle EditorBaseApplication::CreateEntity(const std::string& name)
{
entt::handle entity = m_level.CreateEntity();
Nz::EditorNameComponent& nameComponent = entity.emplace<Nz::EditorNameComponent>();
nameComponent.SetName(name);
entity.emplace<Nz::NodeComponent>();
OnEntityCreated(entity);

View File

@ -44,7 +44,7 @@ int WinMain(int argc, char* argv[])
.type(entt::type_hash<Nz::EditorNameComponent>::value())
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::EditorNameComponent>>(entt::hashed_string("Reflect"));
entt::handle entity = app.CreateEntity();
entt::handle entity = app.CreateEntity("TestEntity");
return app.Run();
}