msw-ui-system
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemsw-ui-system
MSW UI系统
MSW single entry point — design guide + component API + builder invocation + runtime patterns bundled into one skill.
.uiRole division with existing skills:
| Skill | Responsibility |
|---|---|
| Everything |
| Pre-built style bundles — |
MSW 单一入口点 —— 整合了设计指南 + 组件API + 构建器调用 + 运行时模式的一站式技能。
.ui与现有技能的职责划分:
| 技能 | 职责 |
|---|---|
| 所有与 |
| 预构建样式包 —— |
0. Routing
0. 路由规则
Branch to sub-references based on request keywords.
| Trigger | Reference Document |
|---|---|
| "anchor/pivot/coordinates/why is the position wrong", "RectTransform", "stretch" | |
| "mobile", "safe area", "1920", "MobileOnly", "ActivePlatform", "touch size", "PC reserved zone", "font size by device" | |
| "UIGroup", "above popup", "z-order", "displayOrder", "CanvasGroup", "opacity propagation", "Enable vs Visible" | |
| "which component", "Sprite vs Text vs Button", "9-slice", "scroll list", "GridView vs ScrollLayoutGroup" | |
| "make a HUD", "popup placement", "toast", "menu", "inventory grid", "scroll list" | |
| "connect .mlua after building with .ui builder", "property default UUID", "binding without drag" | |
Runtime UI component field read/write, component property name/type ( | |
Enum values ( | |
| Runtime mlua patterns (popup open/close, toast fade, HP bar, GridView, drag, tab, cooldown), Runtime UI Caveats (client-only, server-side nil, etc.) | |
| |
根据请求关键词跳转至子参考文档。
| 触发关键词 | 参考文档 |
|---|---|
| "anchor/pivot/coordinates/位置为什么不对"、"RectTransform"、"stretch" | |
| "mobile"、"安全区域"、"1920"、"MobileOnly"、"ActivePlatform"、"触摸尺寸"、"PC预留区域"、"按设备设置字体大小" | |
| "UIGroup"、"弹窗层级"、"z-order"、"displayOrder"、"CanvasGroup"、"透明度继承"、"Enable与Visible的区别" | |
| "选哪个组件"、"Sprite vs Text vs Button"、"9-slice"、"滚动列表"、"GridView vs ScrollLayoutGroup" | |
| "制作HUD"、"弹窗定位"、"提示框"、"菜单"、"背包网格"、"滚动列表" | |
| "用.ui构建器创建后关联.mlua"、"属性默认UUID"、"无需拖拽的绑定" | |
运行时UI组件字段读写、组件属性名称/类型( | |
枚举值( | |
| .mlua运行时模式(弹窗开关、提示框淡入淡出、血条、GridView、拖拽、标签页、冷却计时)、运行时UI注意事项(仅客户端可用、服务器端为nil等) | |
| |
1. Basic Workflow
1. 基本工作流程
(1) Clarify intent Layout sketch (ASCII or verbal) + which group to attach to
(2) Check design guide Match at least one of ui-fundamentals / ui-hierarchy / component-api §Component Selection Guide
(3) Match recipe Select the closest template from layout-recipes.md
(4) Invoke builder Create/patch via scripts/msw_ui_builder.cjs (protocol: builder-protocol.md)
(5) Inject bindings Auto-inject .mlua property default UUIDs via b.write(path, { bind: {...} }) or b.inject_bindings(...) (builder-protocol.md §"Binding Injection")
(6) Self-verify write() auto-runs scripts/ui_lint.cjs (strict ON by default)
(7) Preview Visual check via scripts/preview_ui_layout.cjs
(8) Maker Refresh Apply to engine(1) 明确需求 布局草图(ASCII或文字描述)+ 要挂载的组
(2) 查阅设计指南 至少匹配ui-fundamentals / ui-hierarchy / component-api中的「组件选择指南」章节
(3) 匹配布局方案 从layout-recipes.md中选择最接近的模板
(4) 调用构建器 通过scripts/msw_ui_builder.cjs创建/修改(协议参考builder-protocol.md)
(5) 注入绑定 通过b.write(path, { bind: {...} })或b.inject_bindings(...)自动注入.mlua属性默认UUID(参考builder-protocol.md的「绑定注入」章节)
(6) 自我验证 write()会自动运行scripts/ui_lint.cjs(默认开启严格模式)
(7) 预览 通过scripts/preview_ui_layout.cjs进行视觉检查
(8) 刷新编辑器 应用到引擎2. Global Rules
2. 全局规则
NEVER
禁止操作
- Do not directly edit JSON —
.uicreation/modification must go through.ui. Manual editing breaks UUID·ValueType·scripts/msw_ui_builder.cjsconsistency and causes silent drops.@components - Read existing files through the builder too — Query via
.ui/UIBuilder.read(filepath)/.find(). Do not directly grep/parse raw JSON..list_entities()- direct
.uiand shell commands such asRead/cat/type/Get-Content/rg/grep/sed/awk/cpare blocked by the registered guard. Usemvfor reads andUIBuilder.read/load/snapshotfor writes. Deleting an entireb.write()file is a separate explicit deletion action, not a builder mutation..ui
- Set directly — Use only
Position(Position is engine-managed)anchoredPosition - Express size via OffsetMin/Max on fixed anchors (AnchorsMin == AnchorsMax) while also using — Do not mix the two modes
anchoredPosition - Builder creates new UUIDs but property defaults are not updated — Binding breaks
.mlua
- 禁止直接编辑JSON文件 ——
.ui的创建/修改必须通过.ui进行。手动编辑会破坏UUID·ValueType·scripts/msw_ui_builder.cjs的一致性,导致静默丢失数据。@components - 读取现有文件也必须通过构建器 —— 通过
.ui/UIBuilder.read(filepath)/.find()查询。禁止直接查找/解析原始JSON。.list_entities()- 直接读取文件和使用
.ui/cat/type/Get-Content/rg/grep/sed/awk/cp等shell命令已被防护机制阻止。读取请使用mv,写入请使用UIBuilder.read/load/snapshot。删除整个b.write()文件是独立的显式操作,不属于构建器修改范畴。.ui
- 直接读取
- 直接设置—— 仅使用
Position(Position由引擎管理)anchoredPosition - 在固定锚点(AnchorsMin == AnchorsMax)模式下同时用OffsetMin/Max定义尺寸和—— 禁止混合两种模式
anchoredPosition - 构建器生成新UUID但未更新属性默认值 —— 会导致绑定失效
.mlua
ALWAYS
必须遵守
- Check at least one design guide before invoking the builder (/
ui-fundamentals/ui-hierarchy§Component Selection Guide)component-api - Match a recipe first; build from scratch only as a last resort
- For edge placement use the formula:
pos = ±(margin + size/2) - Separate popups and toasts into their own UIGroup, standalone show/hide
- Verify text default is
Alignment— 95% of "I centered it but it sticks to the left" issuesUpperLeft(0) - Button touch target ≥ 88×88 (mobile support)
- 调用构建器前至少查阅一份设计指南(/
ui-fundamentals/ui-hierarchy中的「组件选择指南」章节)component-api - 优先匹配现有布局方案;仅在万不得已时才从零开始构建
- 边缘定位使用公式:
pos = ±(margin + size/2) - 将弹窗和提示框单独放入专属UIGroup,独立控制显示/隐藏
- 验证文本默认值为
Alignment—— 95%的「我设置了居中但它靠左」问题源于此UpperLeft(0) - 按钮触摸目标区域≥88×88(适配移动端)
3. Sub-documents
3. 子文档
- — Coordinate system, RectTransform 3 elements, anchor mode determination (§1–§8) + Resolution·safe area·PC reserved zones·touch targets·font sizes·platform separation (§9)
references/ui-fundamentals.md - — UIGroup / displayOrder / CanvasGroup / Enable vs Visible
references/ui-hierarchy.md - — §"Component Selection Guide" (which/when/why) + full component property/method/event tables (what) + all UI-related enum values (§Enums)
references/component-api.md - — Layout template collection
references/layout-recipes.md - —
references/runtime-patterns.mdruntime patterns (popup/toast/HP/grid/drag…) + Runtime UI Caveats.mlua - —
references/builder-protocol.mdCJS builder call protocol (panel/text/sprite/button/slider/scroll/script/group/mask/grid/avatar/touch_receive/skeleton/area_particle/basic_particle, component add/replace/patch/remove, anchor presets, write auto-lint,.uiproperty UUID auto-binding).mlua - — Pre-built style bundle index (
references/templates/templates.mdstyle-N-*,.ui,ruid-map.md)Popupbutton.mlua
- —— 坐标系、RectTransform三要素、锚点模式判定(§1–§8)+ 分辨率·安全区域·PC预留区域·触摸目标·字体大小·平台区分(§9)
references/ui-fundamentals.md - —— UIGroup / displayOrder / CanvasGroup / Enable与Visible的区别
references/ui-hierarchy.md - —— 「组件选择指南」章节(选什么/何时用/为什么用)+ 完整组件属性/方法/事件表(是什么)+ 所有UI相关枚举值(「枚举」章节)
references/component-api.md - —— 布局模板集合
references/layout-recipes.md - ——
references/runtime-patterns.md运行时模式(弹窗/提示框/血条/网格/拖拽…)+ 运行时UI注意事项.mlua - ——
references/builder-protocol.mdCJS构建器调用协议(面板/文本/精灵/按钮/滑块/滚动/脚本/组/遮罩/网格/头像/触摸接收/骨骼/区域粒子/基础粒子,组件添加/替换/修补/移除,锚点预设,写入自动校验,.ui属性UUID自动绑定).mlua - —— 预构建样式包索引(
references/templates/templates.mdstyle-N-*、.ui、ruid-map.md)Popupbutton.mlua
4. Scripts
4. 脚本工具
- —
scripts/msw_ui_builder.cjsbuilder core (UIBuilder class). Read.uifor the call protocol before usereferences/builder-protocol.md - —
scripts/preview_ui_layout.cjslayout visual check + touch target warnings.ui - —
scripts/ui_lint.cjsfile self-verification (auto-called by.ui)write() - — Recipe-based scaffolding
scripts/ui_recipe.cjs
- ——
scripts/msw_ui_builder.cjs构建器核心(UIBuilder类)使用前请阅读.ui中的调用协议references/builder-protocol.md - ——
scripts/preview_ui_layout.cjs布局视觉检查 + 触摸目标区域警告.ui - ——
scripts/ui_lint.cjs文件自我验证(由.ui自动调用)write() - —— 基于布局方案的脚手架工具
scripts/ui_recipe.cjs
Out of Scope
超出范围的内容
- /
.map/.modelbuilders — Outside this skill's scope.tileset - JSON schema (raw field shapes,
.ui/@typewrapping, AlignmentOption 0–15 mapping, etc.) — Handled internally by the builder. Users/AI do not need to know directly@components - Accessibility patterns (alt text, screen-reader hints, focus order) — Not covered
- Error-state UI patterns (disabled-button styling beyond , validation messages, loading spinners) — Not covered; design ad-hoc per project
Transition.Disabled - Automated UI testing / layout assertions beyond and
ui_lint.cjs— Not providedpreview_ui_layout.cjs - Custom shader materials () — Field is exposed but authoring shaders is outside this skill's scope
MaterialId
- /
.map/.model构建器 —— 不属于本技能范畴.tileset - JSON schema(原始字段结构、
.ui/@type包装、AlignmentOption 0–15映射等)—— 由构建器内部处理,用户/AI无需直接了解@components - 无障碍模式(替代文本、屏幕阅读器提示、焦点顺序)—— 未覆盖
- 错误状态UI模式(之外的禁用按钮样式、验证消息、加载动画)—— 未覆盖;需根据项目按需设计
Transition.Disabled - 超出和
ui_lint.cjs之外的自动化UI测试/布局断言 —— 未提供preview_ui_layout.cjs - 自定义着色器材质()—— 字段已暴露,但着色器创作不属于本技能范畴
MaterialId