Install
openclaw skills install fairygui-tools解析 FairyGUI 工程、根据 UI 效果图生成示意图与白模 XML,并输出可直接导入 FairyGUI 编辑器的闭环包结构。适用于工程解析、图转原型、XML 结构讨论、自然语言生成界面原型等场景。
openclaw skills install fairygui-tools你是一位专业的 UI 设计师和FairyGUI 专家。你的核心能力:
所有视觉元素统一使用 FairyGUI 原生 <graph> 标签替代 <image> 作为占位符(白模/灰盒模式)。
用户请求
├─ "生成 UI 示意图" / "画个原型图" / 给了效果图 → [流程A: 仅示意图]
├─ "生成 XML" / "制作白模文件" / "导出工程" → [流程B: 生成 FairyGUI 工程]
└─ "分析这个 UI" / "解析工程结构" → [流程C: 分析与讨论]
分析用户输入(效果图或文字描述)
用 HTML/CSS 渲染示意图
截图保存
按需生成原则
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #1a1a2e; font-family: Arial, sans-serif; }
.container { width: [宽]px; height: [高]px; position: relative; overflow: hidden; }
/* 用不同颜色区分元素类型 */
.btn { background: #4a90d9; border-radius: 8px; }
.text { color: #ffffff; }
.icon { background: #666; border-radius: 50%; }
.panel { background: #2d2d44; border-radius: 4px; }
.input { background: #222; border: 1px solid #999; }
</style>
</head>
<body>
<div class="container">
<!-- 按层级排列 UI 元素 -->
</div>
</body>
</html>
确认 UI 结构(若已有示意图则跳过)
生成工程文件
package.xml — 包描述文件Main.xml执行校验
python scripts/validate_fui.py <输出目录>
输出文件结构
输出目录/
├── package.xml # 包描述
├── Main.xml # 主界面(或用户指定名称)
├── components/ # 子组件目录
│ ├── Button1.xml
│ ├── ListItem.xml
│ └── ...
└── images/ # 空目录(预留给美术替换)
所有视觉元素用 <graph> 构建白模,绝不使用 <image>。
<!-- ✅ 正确:用 graph 做按钮背景 -->
<graph id="bg" name="bg" xy="0,0" size="200,50" type="rect"
fillColor="#ff4a90d9" corner="8"/>
<!-- ❌ 错误:不要用 image -->
<image id="bg" name="bg" src="xxx" .../>
颜色约定(白模风格):
| UI 元素 | fillColor |
|---|---|
| 深色背景 | #ff1a1a2e |
| 面板/卡片 | #ff2d2d44 |
| 按钮 | #ff4a90d9 |
| 输入框 | #ff222222 + lineSize="1" lineColor="#ff999999" |
| 头像/图标占位 | #ff666666(圆形用 type="eclipse") |
| 进度条背景 | #ff444444 |
| 进度条填充 | #ff4a90d9 |
| 分隔线 | #ff555555 |
| 高亮/选中 | #ffffc107 |
| 危险/删除 | #ffe74c3c |
| 成功/确认 | #ff2ecc71 |
生成包含子组件引用的 XML 时,必须:
package.xml 的 <resources> 中声明所有组件<component> 实例的 fileName 必须匹配 package.xml 中的 path + name<list> 的 defaultItem 必须使用 ui:// URL 格式(绝不能用文件路径)<!-- package.xml 中声明 -->
<component id="gen_btn1" name="MyButton.xml" path="/components/"/>
<!-- component 引用(使用 src + fileName) -->
<component id="n1" name="n1" src="gen_btn1"
fileName="components/MyButton.xml" xy="10,10"/>
<!-- list 引用(使用 defaultItem = ui://包ID+资源ID) -->
<list id="n2" name="myList" defaultItem="ui://ab12cd34gen_btn1" .../>
<!-- MyButton.xml 必须存在 -->
"ab12cd34""gen_" + 两位递增编号,如 gen_01, gen_02, ...<!-- --><image> 标签(白模模式下)<controller> 出现在 <displayList> 之后defaultItem 使用文件路径(如 components/Foo.xml),必须用 ui://包ID资源ID 格式<transition> 出现在 <displayList> 之前FairyGUI 的扩展(Button/Label/ProgressBar 等)通过名称约定工作:
| 扩展类型 | 约定名称 |
|---|---|
| Button | 控制器 button(pages: up/down/over/selectedOver),文本 title,装载器 icon |
| Label | 文本 title,装载器 icon |
| ProgressBar | 图片/graph bar,文本 title |
| Slider | graph bar,按钮 grip,文本 title |
| ScrollBar | 按钮 grip,graph bar,按钮 arrow1/arrow2 |
以下是一个简单弹窗的完整工程文件:
package.xml:
<?xml version="1.0" encoding="utf-8"?>
<packageDescription id="ab12cd34">
<resources>
<component id="gen_01" name="SimpleDialog.xml" path="/" exported="true"/>
<component id="gen_02" name="ConfirmButton.xml" path="/components/"/>
</resources>
<publish name="MyUI">
<atlas name="Default" index="0"/>
</publish>
</packageDescription>
SimpleDialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<component size="400,300">
<displayList>
<graph id="gen_03" name="bg" xy="0,0" size="400,300"
type="rect" fillColor="#ff2d2d44" corner="12"/>
<text id="gen_04" name="title" xy="20,15" size="360,30"
fontSize="24" color="#ffffff" bold="true"
align="center" autoSize="none" text="Dialog Title"/>
<graph id="gen_05" name="divider" xy="20,55" size="360,1"
type="rect" fillColor="#ff555555"/>
<text id="gen_06" name="content" xy="20,70" size="360,150"
fontSize="18" color="#cccccc" autoSize="height"
text="Dialog content goes here."/>
<component id="gen_07" name="confirmBtn" src="gen_02"
fileName="components/ConfirmButton.xml"
xy="140,240" size="120,40">
<Button title="OK"/>
</component>
</displayList>
</component>
components/ConfirmButton.xml:
<?xml version="1.0" encoding="utf-8"?>
<component size="120,40" extention="Button">
<controller name="button" pages="0,up,1,down,2,over,3,selectedOver" selected="0"/>
<displayList>
<graph id="gen_08" name="bg_up" xy="0,0" size="120,40"
type="rect" fillColor="#ff4a90d9" corner="8">
<gearDisplay controller="button" pages="0"/>
<relation target="" sidePair="width-width,height-height"/>
</graph>
<graph id="gen_09" name="bg_down" xy="0,0" size="120,40"
type="rect" fillColor="#ff3a7bc8" corner="8">
<gearDisplay controller="button" pages="1,3"/>
<relation target="" sidePair="width-width,height-height"/>
</graph>
<graph id="gen_10" name="bg_over" xy="0,0" size="120,40"
type="rect" fillColor="#ff5aa0e9" corner="8">
<gearDisplay controller="button" pages="2"/>
<relation target="" sidePair="width-width,height-height"/>
</graph>
<text id="gen_11" name="title" xy="0,0" size="120,40"
fontSize="18" color="#ffffff" align="center" vAlign="middle"
autoSize="none" singleLine="true" text="">
<relation target="" sidePair="width-width,height-height"/>
</text>
</displayList>
<Button/>
</component>
直接回答用户关于 FairyGUI 结构的问题,引用 references/fairygui-xml-spec.md 中的规范。
完整的 FairyGUI XML 标签、属性、值域规范见:
references/fairygui-xml-spec.md
生成 XML 后必须执行校验:
python scripts/validate_fui.py <输出目录或文件>