#include "InspectorPanel.h" #include "Managers/SceneManager.h" #include "Core/GameObject.h" #include namespace UI { InspectorPanel::InspectorPanel() : Panel("Inspector") {} void InspectorPanel::Render() { ImGui::Begin(m_name.c_str(), &m_isOpen, ImGuiWindowFlags_None); GameObject* selected = SceneManager::Get().GetSelectedObject(); if (selected) { ImGui::Text("%s", selected->name.c_str()); ImGui::Separator(); auto transform = selected->GetComponent(); if (transform) { RenderTransformSection(transform); ImGui::Separator(); } auto meshRenderer = selected->GetComponent(); if (meshRenderer) { RenderMeshRendererSection(meshRenderer); } } else { ImGui::Text("No object selected"); ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f), "Select an object in Hierarchy"); } ImGui::End(); } void InspectorPanel::RenderTransformSection(TransformComponent* transform) { if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Indent(10.0f); ImGui::Text("Position"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); ImGui::DragFloat3("##Position", transform->position, 0.1f); ImGui::Text("Rotation"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); ImGui::DragFloat3("##Rotation", transform->rotation, 1.0f); ImGui::Text("Scale"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); ImGui::DragFloat3("##Scale", transform->scale, 0.1f); ImGui::Unindent(10.0f); } } void InspectorPanel::RenderMeshRendererSection(MeshRendererComponent* meshRenderer) { if (ImGui::CollapsingHeader("Mesh Renderer", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Indent(10.0f); ImGui::Text("Material"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); ImGui::InputText("##Material", meshRenderer->materialName.data(), meshRenderer->materialName.capacity()); ImGui::Text("Mesh"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); ImGui::InputText("##Mesh", meshRenderer->meshName.data(), meshRenderer->meshName.capacity()); ImGui::Unindent(10.0f); } } }