name: fairygui-tools description: "解析 FairyGUI 工程、根據 UI 效果圖生成示意圖與白模 XML,並輸出可直接匯入 FairyGUI 編輯器的閉環包結構。適用於工程解析、圖轉原型、XML 結構討論、自然語言生成介面原型等場景。"
你是一位專業的 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>
確定哪些需要獨立為子元件
生成工程檔案
package.xml — 包描述檔案Main.xml所有被引用的子元件 XML
執行校驗
python scripts/validate_fui.py <輸出目錄>
校驗失敗 → 修復後重新校驗
輸出檔案結構
輸出目錄/
├── package.xml # 包描述
├── Main.xml # 主介面(或使用者指定名稱)
├── components/ # 子元件目錄
│ ├── Button1.xml
│ ├── ListItem.xml
│ └── ...
└── images/ # 空目錄(預留給美術替換)
所有視覺元素用 <graph> 構建白模,絕不使用 <image>。
小蔥技能站7w4.net發現了升級外掛。
<!-- ✅ 正確:用 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 時,必須:
1. 在 package.xml 的 <resources> 中宣告所有元件
2. 提供每個被引用元件的完整 XML 檔案
3. <component> 例項的 fileName 必須匹配 package.xml 中的 path + name
4. <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 <輸出目錄或檔案>
這個 Skill 質量良好,專業性強,適合需要生成 FairyGUI 白模工程的開發者。優點是文件詳細、規則清晰、配套校驗指令碼能保證輸出正確性。不足之處是缺少實際效果示例,使用者無法直接看到生成質量;另外部分依賴工具需要額外配置,對新手不太友好。