feat: expand editor scripting asset and viewport flow

This commit is contained in:
2026-04-03 13:22:30 +08:00
parent ed8c27fde2
commit a05d0b80a2
124 changed files with 10397 additions and 1737 deletions

View File

@@ -1,183 +1,87 @@
# UI Editor
# Legacy UI Prototype
Unity 风格的编辑器 UI使用 ImGui 实现,作为 XCEngine 游戏引擎编辑器的一部分
`mvs/ui/` 是仓库里保留的早期 ImGui + D3D12 编辑器原型。它主要用于保留原始 UI 骨架、交互想法和历史实现参考,不是当前 XCEngine 的正式 editor 主线
## 简介
当前正式 editor 在:
XCGameEngine UI 是一个仿 Unity 编辑器的桌面应用程序,提供场景管理、层级视图、属性检查器等功能。
- [editor/README.md](D:\Xuanchi\Main\XCEngine\editor\README.md)
## 技术栈
当前正式构建入口在仓库根目录:
- **渲染 API**: DirectX 12
- **UI 框架**: ImGui
- **语言**: C++17
- **构建系统**: CMake
- **依赖库**: DirectX 12 SDK
- [README.md](D:\Xuanchi\Main\XCEngine\README.md)
- [AGENT.md](D:\Xuanchi\Main\XCEngine\AGENT.md)
## 项目结构
## 当前状态
```
ui/
这个模块仍然可以单独构建,但它有几个需要明确的事实:
- 顶层 `CMakeLists.txt` 当前并不会纳入 `mvs/ui/`
- 它使用独立的 `mvs/ui/CMakeLists.txt`
- target 名称仍然是历史遗留的 `XCVolumeRendererUI2`
- 它不是当前 `editor/` 目录下那套 `ViewportHostService + Rendering + Project.xcproject + ScriptAssemblies` 架构
- 它不代表当前仓库的真实 editor 能力边界
因此:
- 想用当前引擎编辑器,请进入 `editor/`
- 想研究早期 UI 原型、旧面板布局和最初的 ImGui 宿主结构,可以看这里
## 这个目录里有什么
```text
mvs/ui/
├── CMakeLists.txt
├── README.md
├── src/
│ ├── main.cpp # 程序入口
│ ├── Application.cpp/h # 应用主类
│ ├── Theme.cpp/h # 主题系统
│ ├── Core/
│ │ ├── GameObject.h # 游戏对象
│ │ └── LogEntry.h # 日志条目
│ ├── Managers/
│ ├── LogSystem.cpp/h # 日志系统
│ ├── ProjectManager.cpp/h # 项目管理
│ ├── SceneManager.cpp/h # 场景管理
│ └── SelectionManager.cpp/h # 选择管理
── panels/
├── Panel.cpp/h # 面板基类
│ ├── MenuBar.cpp/h # 菜单栏
│ ├── HierarchyPanel.cpp/h # 层级面板
│ ├── InspectorPanel.cpp/h # 检查器面板
│ ├── SceneViewPanel.cpp/h # 场景视图
│ ├── GameViewPanel.cpp/h # 游戏视图
│ ├── ProjectPanel.cpp/h # 项目面板
│ └── ConsolePanel.cpp/h # 控制台面板
├── bin/Release/ # 输出目录
│ ├── XCVolumeRendererUI2.exe # 可执行文件
│ ├── imgui.ini # ImGui 配置
│ └── Assets/
│ └── Models/
│ └── Character.fbx # 示例模型
├── build/ # 构建目录
└── CMakeLists.txt # CMake 配置
│ ├── panels/
│ ├── Application.cpp
│ ├── Application.h
├── Theme.cpp
── Theme.h
└── main.cpp
├── build/ # 历史本地构建输出
└── bin/ # 历史可执行文件输出
```
## 构建方法
主要内容是:
### 前置要求
- 早期 `Application` / `Theme` 实现
- 基础 `Hierarchy / Scene / Game / Inspector / Project / Console` 面板骨架
- 旧版 `SceneManager / ProjectManager / LogSystem`
- Windows 10/11
- Visual Studio 2019 或更高版本
- CMake 3.15+
## 单独构建方式
### 构建步骤
如果你只是想启动这个原型,可以单独进入该目录配置:
```bash
cd ui
mkdir build && cd build
cmake ..
cmake --build . --config Release
cmake -S mvs/ui -B mvs/ui/build -A x64
cmake --build mvs/ui/build --config Release
```
### 运行
输出可执行文件通常位于:
```bash
# 运行编译好的可执行文件
.\bin\Release\XCGameEngineUI.exe
.\mvs\ui\bin\Release\XCVolumeRendererUI2.exe
```
## 功能特性
## 与当前正式 editor 的区别
### 编辑器面板
当前正式 editor 具备而这个原型没有正式接入的能力包括:
#### 菜单栏MenuBar
- 文件菜单(新建、打开、保存等)
- 编辑菜单(撤销、重做等)
- 视图菜单(面板显示/隐藏)
- 帮助菜单
- `engine/Rendering` 主链驱动的 scene/game viewport
- `ViewportHostService`
- object-id picking 与 outline
- `Project.xcproject`
- `Assets + .meta + Library`
- `project/Library/ScriptAssemblies`
- `ScriptComponent` Inspector 与脚本类发现
#### 层级面板Hierarchy Panel
- 显示场景中所有游戏对象
- 树形结构展示父子关系
- 支持对象选择
- 对象重命名
所以这个目录更适合被理解为:
#### 检查器面板Inspector Panel
- 显示选中对象的属性
- 支持组件编辑
- 变换组件(位置、旋转、缩放)
- 材质组件
- 历史设计参考
- 原型实现存档
- 某些 UI 想法的对照样本
#### 场景视图Scene View
- 3D 场景预览
- 相机控制(平移、旋转、缩放)
- 对象选择
- 辅助工具(网格、轴心)
#### 游戏视图Game View
- 游戏运行时的画面预览
- 分辨率设置
- 宽高比选择
#### 项目面板Project Panel
- 项目文件浏览器
- 资源组织
- 搜索过滤
#### 控制台面板Console Panel
- 日志输出
- 警告和错误显示
- 日志级别过滤
- 清空日志
### 管理系统
#### 日志系统LogSystem
- 分级日志Info、Warning、Error
- 时间戳
- 日志持久化
#### 项目管理ProjectManager
- 项目创建/打开
- 资源路径管理
#### 场景管理SceneManager
- 场景加载/保存
- 对象生命周期管理
#### 选择管理SelectionManager
- 当前选中对象追踪
- 多选支持
### 主题系统
- 深色主题Dark Theme
- 可自定义配色方案
## 窗口布局
默认布局采用经典的 Unity 编辑器风格:
```
+----------------------------------------------------------+
| 菜单栏 |
+----------+------------------------+----------------------+
| | | |
| 项目 | 场景视图 | 检查器 |
| 面板 | | |
| | | |
+----------+------------------------+----------------------+
| 层级面板 | 游戏视图 |
| | |
+------------------------------------+----------------------+
| 控制台面板 |
+----------------------------------------------------------+
```
## 依赖说明
- ImGui - 跨平台 GUI 库
- DirectX 12 - 渲染 API
- Windows SDK - 窗口管理
## 扩展开发
### 添加新面板
1.`panels/` 目录下创建新的面板类
2. 继承 `Panel` 基类
3. 实现 `Render()` 方法
4.`Application` 中注册新面板
### 添加新组件
1. 定义组件类
2.`GameObject` 中注册组件类型
3.`InspectorPanel` 中添加属性编辑器
而不是当前 XCEngine editor 的入口。