Editor: 更新编辑器面板和UI控件系统
- 添加新的UI控件系统(Core.h, ScalarControls.h, VectorControls.h, UI.h) - 更新SceneManager支持场景层级管理 - 优化SelectionManager选择管理 - 改进InspectorPanel/GameViewPanel/HierarchyPanel等面板 - 更新RHI文档说明Vulkan实现计划
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include "InspectorPanel.h"
|
||||
#include "Managers/SceneManager.h"
|
||||
#include "Managers/SelectionManager.h"
|
||||
#include "UI/UI.h"
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace UI {
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
|
||||
InspectorPanel::InspectorPanel() : Panel("Inspector") {
|
||||
m_selectionHandlerId = SelectionManager::Get().OnSelectionChanged.Subscribe([this](uint64_t) {
|
||||
@@ -19,7 +20,7 @@ InspectorPanel::~InspectorPanel() {
|
||||
void InspectorPanel::Render() {
|
||||
ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None);
|
||||
|
||||
XCEngine::Components::GameObject* entity = SelectionManager::Get().GetSelectedEntity();
|
||||
::XCEngine::Components::GameObject* entity = SelectionManager::Get().GetSelectedEntity();
|
||||
|
||||
if (entity) {
|
||||
RenderEntity(entity);
|
||||
@@ -31,17 +32,18 @@ void InspectorPanel::Render() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void InspectorPanel::RenderEntity(XCEngine::Components::GameObject* entity) {
|
||||
void InspectorPanel::RenderEntity(::XCEngine::Components::GameObject* entity) {
|
||||
ImGui::Text("%s", entity->GetName().c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
for (auto& component : entity->m_components) {
|
||||
RenderComponent(component.get());
|
||||
auto components = entity->GetComponents<::XCEngine::Components::Component>();
|
||||
for (auto* component : components) {
|
||||
RenderComponent(component);
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorPanel::RenderComponent(XCEngine::Components::Component* component) {
|
||||
void InspectorPanel::RenderComponent(::XCEngine::Components::Component* component) {
|
||||
if (!component) return;
|
||||
|
||||
const char* name = component->GetName().c_str();
|
||||
@@ -51,20 +53,20 @@ void InspectorPanel::RenderComponent(XCEngine::Components::Component* component)
|
||||
if (ImGui::CollapsingHeader(headerId.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::Indent(10.0f);
|
||||
|
||||
if (auto* transform = dynamic_cast<XCEngine::Components::TransformComponent*>(component)) {
|
||||
glm::vec3 position = transform->GetLocalPosition();
|
||||
glm::vec3 rotation = transform->GetLocalEulerAngles();
|
||||
glm::vec3 scale = transform->GetLocalScale();
|
||||
if (auto* transform = dynamic_cast<::XCEngine::Components::TransformComponent*>(component)) {
|
||||
::XCEngine::Math::Vector3 position = transform->GetLocalPosition();
|
||||
::XCEngine::Math::Vector3 rotation = transform->GetLocalEulerAngles();
|
||||
::XCEngine::Math::Vector3 scale = transform->GetLocalScale();
|
||||
|
||||
if (ImGui::DragFloat3("Position", &position.x, 0.1f)) {
|
||||
if (UI::DrawVec3("Position", position, 0.0f, 80.0f, 0.1f)) {
|
||||
transform->SetLocalPosition(position);
|
||||
}
|
||||
|
||||
if (ImGui::DragFloat3("Rotation", &rotation.x, 1.0f)) {
|
||||
if (UI::DrawVec3("Rotation", rotation, 0.0f, 80.0f, 1.0f)) {
|
||||
transform->SetLocalEulerAngles(rotation);
|
||||
}
|
||||
|
||||
if (ImGui::DragFloat3("Scale", &scale.x, 0.1f)) {
|
||||
if (UI::DrawVec3("Scale", scale, 1.0f, 80.0f, 0.1f)) {
|
||||
transform->SetLocalScale(scale);
|
||||
}
|
||||
}
|
||||
@@ -74,3 +76,4 @@ void InspectorPanel::RenderComponent(XCEngine::Components::Component* component)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user