Update Transform Component view of the editor
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
| #include "Inspector.h" | ||||
|  | ||||
| #include "../TransformVec3.h" | ||||
|  | ||||
| void Inspector::Draw()  | ||||
| { | ||||
| @ -40,9 +40,18 @@ void Inspector::ShowComponents() | ||||
|     if (selected.HasComponent<YoggieEngine::TransformComponent>()) { | ||||
|         auto& transform = selected.GetComponent<YoggieEngine::TransformComponent>(); | ||||
|         if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) { | ||||
| /* | ||||
|             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); | ||||
| */ | ||||
|             auto something = glm::value_ptr(transform.Position); | ||||
|  | ||||
|             ImGuiExtension::TransformVec3("Position", transform.Position); | ||||
|             ImGuiExtension::TransformVec3("Rotation", transform.Rotation); | ||||
|             ImGuiExtension::TransformVec3("Scale", transform.Scale); | ||||
|  | ||||
|  | ||||
|         } | ||||
|         if (selected.HasComponent<YoggieEngine::RelationComponent>()) { | ||||
|             ImGui::Text("Has relation"); | ||||
|  | ||||
							
								
								
									
										59
									
								
								Editor/src/TransformVec3.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								Editor/src/TransformVec3.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | ||||
| #pragma once | ||||
| #include <imgui_widgets.cpp> | ||||
| #include <glm/glm.hpp> | ||||
| namespace ImGuiExtension { | ||||
|  | ||||
|  | ||||
|     void  TransformVec3(const char* label, glm::vec3& vector) { | ||||
|  | ||||
|         ImGui::PushID(label); | ||||
|         ImGui::Columns(2); | ||||
|         ImGui::SetColumnWidth(0, 100.0f); | ||||
|         ImGui::Text(label); | ||||
|  | ||||
|         ImGui::NextColumn(); | ||||
|  | ||||
|         ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth()); | ||||
|         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 }); | ||||
|  | ||||
|         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f,0.2f,0.2f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f,0.1f,0.15f, 1.0f }); | ||||
|         if (ImGui::Button("X")) | ||||
|             vector.x = 0; | ||||
|         ImGui::PopStyleColor(3); | ||||
|  | ||||
|         ImGui::SameLine(); | ||||
|         ImGui::DragFloat("##X", &glm::value_ptr(vector)[0], 0.1f, 0.0f, 0.0f, "%.2f"); | ||||
|         ImGui::PopItemWidth(); | ||||
|         ImGui::SameLine(); | ||||
|  | ||||
|         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f,0.8f,0.3f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f,0.7f,0.2f, 1.0f }); | ||||
|         if (ImGui::Button("Y")) | ||||
|             vector.y = 0; | ||||
|         ImGui::PopStyleColor(3); | ||||
|  | ||||
|         ImGui::SameLine(); | ||||
|         ImGui::DragFloat("##Y", &glm::value_ptr(vector)[1], 0.1f, 0.0f, 0.0f, "%.2f"); | ||||
|         ImGui::PopItemWidth(); | ||||
|         ImGui::SameLine(); | ||||
|  | ||||
|         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f,0.35f,0.9f, 1.0f }); | ||||
|         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f,0.25f,0.8f, 1.0f }); | ||||
|         if (ImGui::Button("Z")) | ||||
|             vector.z = 0; | ||||
|         ImGui::PopStyleColor(3); | ||||
|  | ||||
|         ImGui::SameLine(); | ||||
|         ImGui::DragFloat("##Z", &glm::value_ptr(vector)[2], 0.1f, 0.0f, 0.0f, "%.2f"); | ||||
|         ImGui::PopItemWidth(); | ||||
|         ImGui::PopStyleVar(); | ||||
|  | ||||
|         ImGui::Columns(1); | ||||
|         ImGui::PopID(); | ||||
|  | ||||
|     } | ||||
| } | ||||
| @ -84,9 +84,9 @@ public: | ||||
|             inspector.Update(); | ||||
|             //console.Update(); | ||||
|              | ||||
|             assetsView.Draw(); | ||||
|             assetsView.Update(); | ||||
|  | ||||
|             //ImGui::ShowDemoWindow(); | ||||
|             ImGui::ShowDemoWindow(); | ||||
|             //ImGui::ShowMetricsWindow(); | ||||
|  | ||||
|              | ||||
|  | ||||
		Reference in New Issue
	
	Block a user