From 75aa5772110de73e930c29e2478b87e0c1bcf72d Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Sun, 1 Jan 2023 17:00:48 +0100 Subject: [PATCH] Relation widget + small memory leak solved --- Editor/src/UI/widgets.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Editor/src/UI/widgets.h b/Editor/src/UI/widgets.h index e7ccddc..9e6ddfe 100644 --- a/Editor/src/UI/widgets.h +++ b/Editor/src/UI/widgets.h @@ -60,21 +60,24 @@ public: void ShowComponents(Entity& selected) { auto component = selected.GetComponent(); - char* buf = new char(component.name.size()); - strcpy(buf, component.name.c_str()); - ImGui::InputText("Name:", buf, sizeof(buf), ImGuiInputTextFlags_ReadOnly); + ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly); if (selected.HasComponent()) { auto& transform = selected.GetComponent(); if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.01f); - ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.01f); - ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.01f, 0.0f); + ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.1f); + ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.1f); + ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.1f, 0.0f); + } + if (selected.HasComponent()) { + ImGui::Text("Has relation"); } + } + if (selected.HasComponent()) { auto& render3d = selected.GetComponent(); if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {