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