添加D3D12 ImGui编辑器UI框架

This commit is contained in:
2026-03-12 15:39:40 +08:00
parent e98093da94
commit 44880f03c0
20 changed files with 1241 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
#include "InspectorPanel.h"
#include <imgui.h>
namespace UI {
InspectorPanel::InspectorPanel() : Panel("Inspector") {}
void InspectorPanel::Render() {
ImGui::Begin(m_name.c_str(), &m_isOpen, ImGuiWindowFlags_None);
GameObject* selected = nullptr;
if (m_hierarchyPanel) {
selected = m_hierarchyPanel->GetSelectedObject();
}
if (selected) {
ImGui::Text("%s", selected->name.c_str());
ImGui::Separator();
RenderTransformSection();
ImGui::Separator();
RenderMeshRendererSection();
} 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() {
if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Indent(10.0f);
ImGui::Text("Position");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180);
ImGui::DragFloat3("##Position", m_position, 0.1f);
ImGui::Text("Rotation");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180);
ImGui::DragFloat3("##Rotation", m_rotation, 1.0f);
ImGui::Text("Scale");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180);
ImGui::DragFloat3("##Scale", m_scale, 0.1f);
ImGui::Unindent(10.0f);
}
}
void InspectorPanel::RenderMeshRendererSection() {
if (ImGui::CollapsingHeader("Mesh Renderer", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Indent(10.0f);
ImGui::Text("Material");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180);
static char materialName[64] = "Default-Material";
ImGui::InputText("##Material", materialName, sizeof(materialName));
ImGui::Text("Mesh");
ImGui::SameLine(80);
ImGui::SetNextItemWidth(180);
static char meshName[64] = "Cube Mesh";
ImGui::InputText("##Mesh", meshName, sizeof(meshName));
ImGui::Unindent(10.0f);
}
}
}