add TextComponent

This commit is contained in:
2025-10-31 00:53:18 +08:00
parent 3272797873
commit 66a3171ccd
7 changed files with 131 additions and 42 deletions

View File

@ -9,9 +9,10 @@
#include <imgui_internal.h>
#include <glm/gtc/type_ptr.hpp>
#include <Hazel/Scene/Components.h>
#include "Hazel/UI/UI.h"
#include <misc/cpp/imgui_stdlib.h>
#include "Hazel/Scripting/ScriptEngine.h"
#include "Hazel/UI/UI.h"
namespace Hazel
{
@ -285,6 +286,7 @@ namespace Hazel
DisplayAddComponentEntry<RigidBody2DComponent>("RigidBody 2D");
DisplayAddComponentEntry<BoxCollider2DComponent>("Box Collider 2D");
DisplayAddComponentEntry<CircleCollider2DComponent>("Circle Collider 2D");
DisplayAddComponentEntry<TextComponent>("Text Component");
ImGui::EndPopup();
}
@ -525,6 +527,14 @@ namespace Hazel
ImGui::DragFloat("Restitution", &component.Restitution, 0.01f, 0.0f, 1.0f);
ImGui::DragFloat("Restitution Threshold", &component.RestitutionThreshold, 0.01f, 0.0f);
});
DrawComponent<TextComponent>("Text Renderer", entity, [](auto& component)
{
ImGui::InputTextMultiline("Text string", &component.TextString);
ImGui::ColorEdit4("Color", glm::value_ptr(component.Color));
ImGui::DragFloat("Kerning", &component.Kerning, 0.01f);
ImGui::DragFloat("LineSpacing", &component.LineSpacing, 0.01f);
});
}