feat: 预制体系统与架构改进 (#303)

* feat(prefab): 实现预制体系统和编辑器 UX 改进

## 预制体系统
- 新增 PrefabSerializer: 预制体序列化/反序列化
- 新增 PrefabInstanceComponent: 追踪预制体实例来源和修改
- 新增 PrefabService: 预制体核心服务
- 新增 PrefabLoader: 预制体资产加载器
- 新增预制体命令: Create/Instantiate/Apply/Revert/BreakLink

## 预制体编辑模式
- 支持双击 .prefab 文件进入编辑模式
- 预制体编辑模式工具栏 (保存/退出)
- 预制体实例指示器和操作菜单

## 编辑器 UX 改进
- SceneHierarchy 快捷键: F2 重命名, Ctrl+D 复制, ↑↓ 导航
- 支持双击实体名称内联编辑
- 删除实体时显示子节点数量警告
- 右键菜单添加重命名/复制选项及快捷键提示
- 布局持久化和重置功能

## Bug 修复
- 修复 editor-runtime 组件类重复导致的 TransformComponent 不识别问题
- 修复 .prefab-name 样式覆盖导致预制体工具栏文字不可见
- 修复 Inspector 资源字段高度不正确问题

* feat(editor): 改进编辑器 UX 交互体验

- ContentBrowser: 加载动画 spinner、搜索高亮、改进空状态设计
- SceneHierarchy: 选中项自动滚动到视图、搜索清除按钮
- PropertyInspector: 输入框本地状态管理、Enter/Escape 键处理
- EntityInspector: 组件折叠状态持久化、属性搜索清除按钮
- Viewport: 变换操作实时数值显示
- 国际化: 添加相关文本 (en/zh)

* fix(build): 修复 Web 构建资产加载和编辑器 UX 改进

构建系统修复:
- 修复 asset-catalog.json 字段名不匹配 (entries vs assets)
- 修复 BrowserFileSystemService 支持两种目录格式
- 修复 bundle 策略检测逻辑 (空对象判断)
- 修复 module.json 中 assetExtensions 声明和类型推断

行为树修复:
- 修复 BehaviorTreeExecutionSystem 使用 loadAsset 替代 loadAssetByPath
- 修复 BehaviorTreeAssetType 常量与 module.json 类型名一致 (behavior-tree)

编辑器 UX 改进:
- 构建完成对话框添加"打开文件夹"按钮
- 构建完成对话框样式优化 (圆形图标背景、按钮布局)
- SceneHierarchy 响应式布局 (窄窗口自动隐藏 Type 列)
- SceneHierarchy 隐藏滚动条

错误追踪:
- 添加全局错误处理器写入日志文件 (%TEMP%/esengine-editor-crash.log)
- 添加 append_to_log Tauri 命令

* feat(render): 修复 UI 渲染和点击特效系统

## UI 渲染修复
- 修复 GUID 验证 bug,使用统一的 isValidGUID() 函数
- 修复 UI 渲染顺序随机问题,Rust 端使用 IndexMap 替代 HashMap
- Web 运行时添加 assetPathResolver 支持 GUID 解析
- UIInteractableComponent.blockEvents 默认值改为 false

## 点击特效系统
- 新增 ClickFxComponent 和 ClickFxSystem
- 支持在点击位置播放粒子效果
- 支持多种触发模式和粒子轮换

## Camera 系统重构
- CameraSystem 从 ecs-engine-bindgen 移至 camera 包
- 新增 CameraManager 统一管理相机

## 编辑器改进
- 改进属性面板 UI 交互
- 粒子编辑器面板优化
- Transform 命令系统

* feat(render): 实现 Sorting Layer 系统和 Overlay 渲染层

- 新增 SortingLayerManager 管理排序层级 (Background, Default, Foreground, UI, Overlay)
- 实现 ISortable 接口,统一 Sprite、UI、Particle 的排序属性
- 修复粒子 Overlay 层被 UI 遮挡问题:添加独立的 Overlay Pass 在 UI 之后渲染
- 更新粒子资产格式:从 sortingOrder 改为 sortingLayer + orderInLayer
- 更新粒子编辑器面板支持新的排序属性
- 优化 UI 渲染系统使用新的排序层级

* feat(ci): 集成 SignPath 代码签名服务

- 添加 SignPath 自动签名工作流(Windows)
- 配置 release-editor.yml 支持代码签名
- 将构建改为草稿模式,等待签名完成后发布
- 添加证书文件到 .gitignore 防止泄露

* fix(asset): 修复 Web 构建资产路径解析和全局单例移除

## 资产路径修复
- 修复 Tauri 本地服务器 `/asset?path=...` 路径解析,正确与 root 目录连接
- BrowserPathResolver 支持两种模式:
  - 'proxy': 使用 /asset?path=... 格式(编辑器 Run in Browser)
  - 'direct': 使用直接路径 /assets/path.png(独立 Web 构建)
- BrowserRuntime 使用 'direct' 模式,无需 Tauri 代理

## 架构改进 - 移除全局单例
- 移除 globalAssetManager 导出,改用 AssetManagerToken 依赖注入
- 移除 globalPathResolver 导出,改用 PathResolutionService
- 移除 globalPathResolutionService 导出
- ParticleUpdateSystem/ClickFxSystem 通过 setAssetManager() 注入依赖
- EngineService 使用 new AssetManager() 替代全局实例

## 新增服务
- PathResolutionService: 统一路径解析接口
- RuntimeModeService: 运行时模式查询服务
- SerializationContext: EntityRef 序列化上下文

## 其他改进
- 完善 ServiceToken 注释说明本地定义的意图
- 导出 BrowserPathResolveMode 类型

* fix(build): 添加 world-streaming composite 设置修复类型检查

* fix(build): 移除 world-streaming 引用避免 composite 冲突

* fix(build): 将 const enum 改为 enum 兼容 isolatedModules

* fix(build): 添加缺失的 IAssetManager 导入
This commit is contained in:
YHH
2025-12-13 19:44:08 +08:00
committed by GitHub
parent a716d8006c
commit beaa1d09de
258 changed files with 17725 additions and 3030 deletions

View File

@@ -42,7 +42,8 @@ export const en: Translations = {
type: 'Type',
value: 'Value',
enabled: 'Enabled',
disabled: 'Disabled'
disabled: 'Disabled',
clear: 'Clear'
},
// ========================================
@@ -73,7 +74,8 @@ export const en: Translations = {
forum: 'Forum',
console: 'Console',
assetBrowser: 'Asset Browser',
profiler: 'Profiler'
profiler: 'Profiler',
contentBrowser: 'Content Browser'
},
hierarchy: {
@@ -88,6 +90,7 @@ export const en: Translations = {
createFolder: 'Create Folder',
deleteEntity: 'Delete Entity',
deleteConfirm: 'Are you sure you want to delete entity "{{name}}"?',
deleteConfirmWithChildren: 'Are you sure you want to delete entity "{{name}}" and its {{count}} child(ren)?',
renameEntity: 'Rename Entity',
duplicateEntity: 'Duplicate Entity',
localScene: 'Local Scene',
@@ -113,7 +116,8 @@ export const en: Translations = {
tilemap: 'Tilemap',
camera2d: 'Camera 2D',
particleEffect: 'Particle Effect'
}
},
editingPrefab: 'Editing Prefab'
},
inspector: {
@@ -132,6 +136,43 @@ export const en: Translations = {
empty: 'No components',
add: 'Add Component',
remove: 'Remove'
},
prefab: {
instance: 'Prefab Instance',
source: 'Prefab',
open: 'Open',
select: 'Select',
selectAsset: 'Select Prefab Asset',
revert: 'Revert',
revertAll: 'Revert All',
revertTo: 'Revert to Prefab',
apply: 'Apply',
applyAll: 'Apply All',
applyTo: "Apply to '{{name}}'",
unpack: 'Unpack',
modified: 'Modified',
modifications: '{{count}} modification(s)',
noModifications: 'No modifications',
revertProperty: 'Revert to prefab value',
applyConfirm: 'Apply changes to prefab "{{name}}"?',
revertConfirm: 'Revert all changes to prefab defaults?',
unpackConfirm: 'Unpack prefab instance? This will remove the link to the source prefab.',
applyTitle: 'Apply to Prefab',
revertTitle: 'Revert to Prefab',
unpackTitle: 'Unpack Prefab',
applySuccess: 'Changes applied to prefab',
applyFailed: 'Failed to apply changes to prefab',
revertSuccess: 'Instance reverted to prefab defaults',
revertFailed: 'Failed to revert instance',
unpackSuccess: 'Prefab link broken',
unpackFailed: 'Failed to unpack prefab'
},
array: {
empty: 'Empty array',
add: 'Add',
remove: 'Remove',
dragToReorder: 'Drag to reorder',
dropAsset: 'Drop asset'
}
},
@@ -186,6 +227,15 @@ export const en: Translations = {
},
notifications: {
noScene: 'No Scene'
},
prefab: {
editing: 'Editing',
save: 'Save Prefab',
exit: 'Exit Edit Mode',
saveAndExit: 'Save & Exit',
discardChanges: 'Discard Changes',
savedSuccess: 'Prefab saved: {{name}}',
saveFailed: 'Failed to save prefab'
}
},
@@ -238,7 +288,8 @@ export const en: Translations = {
network: 'Network',
sourceControl: 'Source Control',
allSaved: 'All Saved',
revisionControl: 'Revision Control'
revisionControl: 'Revision Control',
resetLayout: 'Reset Layout'
},
// ========================================
@@ -459,9 +510,16 @@ export const en: Translations = {
saveAll: 'Save All',
search: 'Search',
items: 'items',
searchResults: 'Found {{found}} of {{total}} items',
selectedCount: '{{count}} selected',
dockInLayout: 'Dock in Layout',
noProject: 'No project loaded',
empty: 'This folder is empty',
emptyHint: 'Drag files here or right-click to create new assets',
loading: 'Loading...',
noSearchResults: 'No results found',
noSearchResultsHint: 'Try a different search term',
createNew: 'Create New',
newFolder: 'New Folder',
newPrefix: 'New',
managedDirectoryTooltip: 'GUID-managed directory - Assets here get unique IDs for references',
@@ -684,7 +742,12 @@ export const en: Translations = {
envReady: 'Environment Ready',
envNotReady: 'Environment Issue',
esbuildReady: 'esbuild ready',
esbuildMissing: 'esbuild not found'
esbuildMissing: 'esbuild not found',
esbuildNotInstalled: 'esbuild Installation Required',
esbuildRequired: 'esbuild is required for compiling TypeScript code.',
esbuildInstallPrompt: 'Click the button below to install esbuild globally via npm.',
installingEsbuild: 'Installing esbuild...',
installNow: 'Install Now'
},
// ========================================
@@ -826,7 +889,8 @@ export const en: Translations = {
settings: 'Settings',
copyError: 'Copy error',
showDetails: 'Show details',
collapse: 'Collapse'
collapse: 'Collapse',
openFolder: 'Open Folder'
},
// ========================================

View File

@@ -42,7 +42,8 @@ export const zh: Translations = {
type: '类型',
value: '值',
enabled: '启用',
disabled: '禁用'
disabled: '禁用',
clear: '清除'
},
// ========================================
@@ -73,7 +74,8 @@ export const zh: Translations = {
forum: '论坛',
console: '控制台',
assetBrowser: '资源浏览器',
profiler: '性能分析器'
profiler: '性能分析器',
contentBrowser: '内容管理器'
},
hierarchy: {
@@ -88,6 +90,7 @@ export const zh: Translations = {
createFolder: '创建文件夹',
deleteEntity: '删除实体',
deleteConfirm: '确定要删除实体 "{{name}}" 吗?',
deleteConfirmWithChildren: '确定要删除实体 "{{name}}" 及其 {{count}} 个子节点吗?',
renameEntity: '重命名实体',
duplicateEntity: '复制实体',
localScene: '本地场景',
@@ -113,7 +116,8 @@ export const zh: Translations = {
tilemap: '瓦片地图',
camera2d: '2D 相机',
particleEffect: '粒子效果'
}
},
editingPrefab: '编辑预制体'
},
inspector: {
@@ -132,6 +136,43 @@ export const zh: Translations = {
empty: '无组件',
add: '添加组件',
remove: '移除'
},
prefab: {
instance: '预制体实例',
source: '预制体',
open: '打开',
select: '定位',
selectAsset: '定位预制体资产',
revert: '还原',
revertAll: '全部还原',
revertTo: '还原到预制体',
apply: '应用',
applyAll: '全部应用',
applyTo: "应用到 '{{name}}'",
unpack: '解包',
modified: '已修改',
modifications: '{{count}} 处修改',
noModifications: '无修改',
revertProperty: '还原为预制体值',
applyConfirm: '将修改应用到预制体 "{{name}}"?',
revertConfirm: '将所有修改还原为预制体默认值?',
unpackConfirm: '解包预制体实例?这将断开与源预制体的链接。',
applyTitle: '应用到预制体',
revertTitle: '还原到预制体',
unpackTitle: '解包预制体',
applySuccess: '已应用修改到预制体',
applyFailed: '应用修改到预制体失败',
revertSuccess: '已还原为预制体默认值',
revertFailed: '还原实例失败',
unpackSuccess: '已断开预制体链接',
unpackFailed: '解包预制体失败'
},
array: {
empty: '空数组',
add: '添加',
remove: '删除',
dragToReorder: '拖拽排序',
dropAsset: '拖拽资源'
}
},
@@ -186,6 +227,15 @@ export const zh: Translations = {
},
notifications: {
noScene: '无场景'
},
prefab: {
editing: '编辑中',
save: '保存预制体',
exit: '退出编辑',
saveAndExit: '保存并退出',
discardChanges: '放弃修改',
savedSuccess: '预制体已保存:{{name}}',
saveFailed: '保存预制体失败'
}
},
@@ -238,7 +288,8 @@ export const zh: Translations = {
network: '网络',
sourceControl: '源代码管理',
allSaved: '所有已保存',
revisionControl: '版本控制'
revisionControl: '版本控制',
resetLayout: '重置布局'
},
// ========================================
@@ -459,9 +510,16 @@ export const zh: Translations = {
saveAll: '全部保存',
search: '搜索',
items: '项',
searchResults: '找到 {{found}} / {{total}} 项',
selectedCount: '已选 {{count}} 项',
dockInLayout: '停靠到布局',
noProject: '未加载项目',
empty: '文件夹为空',
emptyHint: '拖放文件到此处或右键创建新资产',
loading: '加载中...',
noSearchResults: '未找到结果',
noSearchResultsHint: '尝试其他搜索词',
createNew: '新建',
newFolder: '新建文件夹',
newPrefix: '新建',
managedDirectoryTooltip: 'GUID 管理的目录 - 此处的资产会获得唯一 ID 以便引用',
@@ -684,7 +742,12 @@ export const zh: Translations = {
envReady: '环境就绪',
envNotReady: '环境问题',
esbuildReady: 'esbuild 就绪',
esbuildMissing: '未找到 esbuild'
esbuildMissing: '未找到 esbuild',
esbuildNotInstalled: '需要安装 esbuild',
esbuildRequired: 'esbuild 是编译 TypeScript 代码所必需的工具。',
esbuildInstallPrompt: '点击下方按钮将使用 npm 全局安装 esbuild。',
installingEsbuild: '正在安装 esbuild...',
installNow: '立即安装'
},
// ========================================
@@ -826,7 +889,8 @@ export const zh: Translations = {
settings: '设置',
copyError: '复制错误信息',
showDetails: '显示详情',
collapse: '收起'
collapse: '收起',
openFolder: '打开文件夹'
},
// ========================================