2026-03-26 01:26:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "IComponentEditor.h"
|
2026-03-26 02:24:11 +08:00
|
|
|
#include "Core/IUndoManager.h"
|
2026-03-26 01:26:26 +08:00
|
|
|
#include "UI/UI.h"
|
|
|
|
|
|
|
|
|
|
#include <XCEngine/Components/TransformComponent.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
|
|
class TransformComponentEditor : public IComponentEditor {
|
|
|
|
|
public:
|
2026-03-26 02:24:11 +08:00
|
|
|
const char* GetComponentTypeName() const override {
|
2026-03-26 01:26:26 +08:00
|
|
|
return "Transform";
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 02:24:11 +08:00
|
|
|
const char* GetDisplayName() const override {
|
|
|
|
|
return "Transform";
|
2026-03-26 01:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 01:59:14 +08:00
|
|
|
bool Render(::XCEngine::Components::Component* component, IUndoManager* undoManager) override {
|
2026-03-26 01:26:26 +08:00
|
|
|
auto* transform = dynamic_cast<::XCEngine::Components::TransformComponent*>(component);
|
|
|
|
|
if (!transform) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::XCEngine::Math::Vector3 position = transform->GetLocalPosition();
|
|
|
|
|
::XCEngine::Math::Vector3 rotation = transform->GetLocalEulerAngles();
|
|
|
|
|
::XCEngine::Math::Vector3 scale = transform->GetLocalScale();
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
|
|
if (UI::DrawVec3("Position", position, 0.0f, 80.0f, 0.1f)) {
|
2026-03-26 01:59:14 +08:00
|
|
|
if (undoManager) {
|
|
|
|
|
undoManager->BeginInteractiveChange("Modify Transform");
|
|
|
|
|
}
|
2026-03-26 01:26:26 +08:00
|
|
|
transform->SetLocalPosition(position);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UI::DrawVec3("Rotation", rotation, 0.0f, 80.0f, 1.0f)) {
|
2026-03-26 01:59:14 +08:00
|
|
|
if (undoManager) {
|
|
|
|
|
undoManager->BeginInteractiveChange("Modify Transform");
|
|
|
|
|
}
|
2026-03-26 01:26:26 +08:00
|
|
|
transform->SetLocalEulerAngles(rotation);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UI::DrawVec3("Scale", scale, 1.0f, 80.0f, 0.1f)) {
|
2026-03-26 01:59:14 +08:00
|
|
|
if (undoManager) {
|
|
|
|
|
undoManager->BeginInteractiveChange("Modify Transform");
|
|
|
|
|
}
|
2026-03-26 01:26:26 +08:00
|
|
|
transform->SetLocalScale(scale);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CanAddTo(::XCEngine::Components::GameObject* gameObject) const override {
|
|
|
|
|
(void)gameObject;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* GetAddDisabledReason(::XCEngine::Components::GameObject* gameObject) const override {
|
|
|
|
|
(void)gameObject;
|
|
|
|
|
return "Built-in";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CanRemove(::XCEngine::Components::Component* component) const override {
|
|
|
|
|
(void)component;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace XCEngine
|