From MonoFSM Framework
Guides extending and modifying the PrefabToTextExporter tool, which converts Unity Prefabs to Godot-style text format for LLM readability. Use when adding export formats, component type mappings, or filter logic.
How this skill is triggered — by the user, by Claude, or both
Slash command
/monofsm:prefab-text-exporterThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
將 Unity Prefab 轉換為 Godot `.tscn` 風格的純文字格式,方便 LLM 閱讀理解場景結構。
將 Unity Prefab 轉換為 Godot .tscn 風格的純文字格式,方便 LLM 閱讀理解場景結構。
MonoFSM/1_MonoFSM_Core/Editor/PrefabExporter/
├── UnityTypeFormatter.cs # 類型格式化(Vector, Color, Object Reference 等)
├── PrefabExportSettings.cs # 設定資料結構 + EditorPrefs 持久化
├── PrefabToTextExporter.cs # 核心轉換邏輯(遍歷 GameObject、比較預設值)
├── PrefabToTextContextMenu.cs # 右鍵選單(Assets/MonoFSM/複製 Prefab 為文字)
└── PrefabToTextWindow.cs # OdinEditorWindow 進階視窗
[gd_scene format=3 uid="unity_prefab"]
[node name="Player" type="RigidBody3D"]
position = Vector3(0, 1, 0)
# Component: Rigidbody
mass = 10
[node name="Arm" type="MeshInstance3D" parent="."]
position = Vector3(0.5, 0, 0)
# Component: MeshRenderer
material = ExtResource("Assets/Materials/Mat.mat")
[node name="Hand" type="Node3D" parent="Arm"]
scale = Vector3(0.5, 0.5, 0.5)
| Unity 類型 | 輸出格式 |
|---|---|
| Vector3 | Vector3(x, y, z) |
| Quaternion | Vector3(euler.x, euler.y, euler.z) |
| Color | Color(r, g, b, a) |
| Asset Reference | ExtResource("Assets/path/to/file.ext") |
| Scene Object | NodePath("Parent/Child") |
| Enum | "EnumValueName" |
| Array | [item1, item2, ...] |
在 FormatValue() 的 switch expression 中新增:
return value switch
{
// 新增自訂類型
MyCustomType custom => $"Custom({custom.field1}, {custom.field2})",
// ... existing cases
};
根據 GameObject 上的 Component 決定 Godot 節點類型:
| Unity Component | Godot Type |
|---|---|
| Camera | Camera3D |
| Rigidbody | RigidBody3D |
| CharacterController | CharacterBody3D |
| MeshRenderer | MeshInstance3D |
| Collider | CollisionShape3D |
| Animator | AnimationPlayer |
| Canvas | CanvasLayer |
| (default) | Node3D |
在 PrefabToTextExporter.DetermineNodeType() 中新增:
if (go.GetComponent<MyComponent>()) return "MyGodotType";
使用臨時 GameObject 建立 Component 預設實例,快取預設值後比較:
// 快取結構
Dictionary<Type, Dictionary<string, object>> _defaultCache
// 比較流程
1. GetDefaultValues(componentType) - 取得或建立預設值快取
2. IsDefaultValue(property, defaults) - 比較當前值與預設值
3. 若相同則跳過輸出
Project 視窗選擇 Prefab → 右鍵 → MonoFSM/複製 Prefab 為文字
Tools → MonoFSM → Prefab Text Exporter
在 PrefabExportSettings._excludedFieldNames 中加入欄位名稱。
修改 PrefabToTextExporter.TraverseGameObject() 中的 StringBuilder 輸出。
在 UnityTypeFormatter.FormatPropertyValue() 的 switch 中新增 case。
npx claudepluginhub red-candle-games-co-ltd/monofsm --plugin monofsmExports Unity GameObject hierarchies and serialized component fields into compact structured text for LLM reading. Use to understand hierarchy context or export prefab/scene subtrees with minimal tokens.
Exports Blender assets to Unity with correct scale, axis, materials, humanoid rigs, LODs, and collision meshes. Uses GLB/FBX based on asset type.
Creates and modifies Unity scene and prefab files by writing editor scripts. Handles GameObjects, uGUI hierarchies, and component wiring.