Unity Prefab XML
XML to Prefab importer for Unity. Designed for LLM-driven prefab generation.
com.codewriter.unity-prefab-xml 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/unity-prefab-xml.git README Markdown
Copy this to your project's README.md
## Installation
Add **Unity Prefab XML** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/unity-prefab-xml.git
```
[](https://www.pkglnk.dev/pkg/unity-prefab-xml)README
Unity Prefab XML

XML to Prefab importer for Unity
A simplified XML format designed for LLM-driven prefab generation. Instead of asking AI to produce complex Unity .prefab YAML files, you describe your prefab in a compact XML — and Unity imports it as a real prefab. Works with any GameObject hierarchy, including UI.
🤔 Why not generate .prefab YAML directly?
Unity prefab files are verbose serialized YAML with internal references, fileIDs, GUIDs, and strict formatting rules. Even small mistakes break the file. This makes them impractical for LLM generation:
- ❌ A simple button is ~100 lines of YAML with cryptic numeric IDs
- ❌ Components reference each other via
fileID— the model has to track and increment IDs correctly - ❌ GUIDs for scripts, sprites, fonts must be looked up from
.metafiles - ❌ Formatting errors or missing fields silently corrupt the prefab
PrefabXML solves this. Compare the same button:
| Unity .prefab YAML (~80 lines) | PrefabXML (8 lines) |
|---|---|
|
|
Save as .prefabxml — Unity imports it as a prefab automatically.
✨ Features
- 🧩 Any component — use any Unity component by class name, including custom scripts with full namespace
- ⚓ Standard Unity field names — uses
m_serialized property names, 1:1 mapping to C# - 🔗 Object references — link components to other GameObjects via
#id - 🎨 Asset references — reference sprites, fonts, materials by project path or via
{name}bindings assigned in the Inspector - 🌳 Nested hierarchies — parent-child relationships through XML nesting
- 🔢 Value types — Color (
#FF0000), Vector2/3/4, Enum, RectOffset, and more - 🎮 Custom MonoBehaviours — add your own scripts and wire
[SerializeField]fields via#idreferences directly in XML (seeSamples/Counter)
🚀 Use cases
- 🤖 AI-generated prefabs — ask an LLM to create UI or scene objects from a text description
- ⚡ Rapid prototyping — sketch out a prefab in a text editor without opening the Unity Inspector
- 📝 Diff-friendly UI — review prefab changes in pull requests as readable XML, not cryptic YAML
🤖 Getting started with LLM
- Add FORMAT.md, GUIDE.md and relevant files from
Templates/to the LLM context - Describe the UI you want: "Create a settings panel with volume slider, music toggle, and resolution dropdown"
- Save the generated XML as
.prefabxmlin your Unity project — it imports as a prefab automatically - Drag the prefab onto a Canvas
Tips:
- Include your existing
.prefabxmlfiles in the prompt so the LLM matches your project's style and uses correct asset paths - Ask the LLM to generate both a C# MonoBehaviour and a
.prefabxmlin one go — the script's[SerializeField]fields can be wired to UI elements via#idreferences (seeSamples/Counterfor an example)
📖 Format & Guide
📂 Samples & Templates
Templates/— reference templates for common UI components (Button, Slider, Toggle, Dropdown, etc.) with all field namesSamples/— complete working examples
🎨 Syntax Highlighting
.prefabxml files are plain XML, so you can enable syntax highlighting in your IDE by associating the extension with the XML file type:
VS Code
Add to your .vscode/settings.json:
{
"files.associations": {
"*.prefabxml": "xml"
}
}
JetBrains Rider
Go to Settings → Editor → File Types, find XML in the list, and add *.prefabxml to the registered patterns.
📦 How to Install
Library distributed as git package (How to install package from git URL)
Git URL: https://github.com/codewriter-packages/Unity-Prefab-XML.git
🤖 Claude Code Integration
Install the /prefabxml skill and agent-prefabxml subagent for Claude Code:
# Install globally (~/.claude, available in all projects)
curl -fsSL https://raw.githubusercontent.com/codewriter-packages/Unity-Prefab-XML/main/install-claude-skill.sh | bash
# Or install into current project only (.claude/)
curl -fsSL https://raw.githubusercontent.com/codewriter-packages/Unity-Prefab-XML/main/install-claude-skill.sh | bash -s -- --local
This adds a Claude Code skill and agent. To update, run the same command again.
Usage:
/prefabxml settings panel with volume slider, music toggle, and resolution dropdown
The subagent can be used for parallel prefab generation — Claude will automatically delegate to agent-prefabxml when generating multiple .prefabxml files at once.
📄 License
Unity Prefab XML is MIT licensed.
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In