【AI编码】增加文档

main
刘涛 2026-02-04 15:05:24 +08:00
parent 6daa2d84e6
commit 2117d091f0
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,38 @@
# UIInfoBuilder
Unity UI Prefab 信息提取工具,将 Prefab 层级结构和组件属性导出为 JSON 文件。
## 用途
- 提取 UI Prefab 的完整结构信息
- 便于 AI 理解和分析 UI 界面
- 支持 UI 文档化和版本对比
## 使用方法
1. 在 Project 窗口选择 Prefab
2. 右键 -> `UIInfoBuilder/ExtractPrefab`
3. JSON 保存到 `项目根目录/ExtractedPrefabs/`
## 架构
```
UIInfoBuilder/
├── UIInfoExtractor.cs # 主入口,递归遍历节点
├── Data/
│ ├── UIInfoNode.cs # 节点数据结构
│ └── UIInfoComponent.cs # 组件数据结构
└── ComponentExtractors/
├── IComponentExtractor.cs # 提取器接口
├── DefaultComponentExtractor.cs # 默认反射提取
├── RectTransformExtractor.cs # RectTransform 精细提取
├── ImageExtractor.cs # Image 精细提取
├── TextExtractor.cs # Text/TMP 精细提取
└── ButtonExtractor.cs # Button 精细提取
```
## 扩展
添加新组件提取器:
1. 实现 `IComponentExtractor` 接口
2. 在 `UIInfoExtractor` 静态构造函数中注册

View File

@ -0,0 +1,46 @@
# UI Prefab JSON 格式说明
## 结构
```
UIInfoNode {
name: string // GameObject 名称
active: boolean // 激活状态
components: [] // 组件列表
children: [] // 子节点(递归)
}
UIInfoComponent {
componentName: string // 组件类型名
enable: boolean // 启用状态
properties: string[] // 属性列表 "Key:Value" 格式
}
```
## 属性格式
| 类型 | 格式示例 |
|------|----------|
| Vector2 | `AnchoredPosition:0,0` |
| Vector3 | `LocalPosition:0,0,0` |
| Color | `Color:#RRGGBBAA` |
| Bool | `RaycastTarget:true` |
| Enum | `ImageType:Sliced` |
| 引用 | `Sprite:sprite_name` 或空 |
## RectTransform 属性
- `AnchorMin/Max:x,y` - 锚点范围
- `Pivot:x,y` - 轴心点
- `AnchoredPosition:x,y` - 锚点位置
- `AnchoredPosition3D:x,y,z` - 3D锚点位置
- `SizeDelta:x,y` - 尺寸增量
- `LocalPosition/Rotation/Scale` - 本地变换
## 常见组件
- **RectTransform**: UI 变换信息
- **Image**: Sprite、Color、ImageType、FillAmount 等
- **Text/TMP_Text**: 文本内容、字体、对齐方式等
- **Button**: Transition 类型、颜色状态等
- **CanvasRenderer**: CullTransparentMesh 等