Unity-AI-Forge - AI-Powered Unity Development
Forge Unity games through AI collaboration. Model Context Protocol integration with GameKit framework.
You are now working with Unity-AI-Forge, a powerful system that lets you create, modify, and manage Unity projects directly from this conversation through intelligent AI collaboration.
Prerequisites
Before using these tools, ensure:
- Unity Editor is open
- MCP Bridge is started (Tools > MCP Assistant > Start Bridge)
- Connection status shows "Connected"
Core Capabilities
🎮 Scene Management
- Quick setup: Instantly create 3D, 2D, UI, or VR scenes with proper configuration
- Scene operations: Create, load, save, delete, and list scenes
- Context inspection: Get real-time scene hierarchy and GameObject information
🎨 GameObject Operations
- Templates: Create common GameObjects (Cube, Sphere, Player, Enemy, etc.) with one command
- CRUD operations: Create, rename, move, duplicate, delete GameObjects
- Batch operations: Find and modify multiple GameObjects using patterns
- Hierarchy builder: Build complex nested structures declaratively
🧩 Component Management
- Add/Remove/Update: Manage components on any GameObject
- Property setting: Set component properties including asset references
- UnityEvent listeners: Configure UI event handlers (Button.onClick, etc.)
- Batch operations: Add/remove/update components on multiple GameObjects
🖼️ UI Creation (UGUI)
- Templates: Create complete UI elements (Button, Panel, ScrollView, Dropdown, etc.)
- Layout management: Add and configure layout groups (Vertical, Horizontal, Grid)
- Anchor presets: Position UI elements correctly on Canvas
📦 Asset & Script Management
- Asset operations: Rename, duplicate, delete, inspect assets and update importer settings
- Script template generation: Generate MonoBehaviour and ScriptableObject templates with proper Unity structure
- Prefab workflow: Create, instantiate, update, apply/revert prefab overrides
- Design patterns: Generate production-ready implementations of common design patterns (Singleton, ObjectPool, StateMachine, Observer, Command, Factory, ServiceLocator)
🎯 Advanced Features
- Project settings: Read/write Unity project settings (player, quality, time, physics, audio, editor)
- Render pipeline: Inspect and configure render pipeline settings (Built-in, URP, HDRP)
- Tags & Layers: Manage project tags and layers, set on GameObjects
- Constants: Convert between Unity constants and numeric values (enums, colors, layers)
🎮 GameKit Framework
Unity-AI-Forge includes the GameKit framework - a high-level game development system with MCP integration.
GameKit provides:
- GameKitActor: Player/NPC controllers with input abstraction
- GameKitManager: Centralized game systems (resources, states, turns)
- GameKitUICommand: Bridge UI buttons to game logic
- GameKitMachinations: Economic systems with flows/converters/triggers
- GameKitSceneFlow: State machine-based scene transitions
- GameKitInteraction: Trigger-based game events
📚 See SKILL_GAMEKIT.md for complete GameKit documentation with examples.
Quick GameKit Examples
# Create a player actor
gamekitActor({
"operation": "create",
"actorId": "Player",
"controlMode": "directController",
"behaviorProfile": "3dCharacterController"
})
# Create a resource manager for RPG
gamekitManager({
"operation": "create",
"managerId": "PlayerStats",
"managerType": "resourcepool",
"initialResources": {
"health": 100,
"mana": 50,
"gold": 0
}
})
# Create UI buttons that control resources
gamekitUICommand({
"operation": "createCommandPanel",
"panelId": "ShopUI",
"canvasPath": "Canvas",
"targetType": "manager",
"targetManagerId": "PlayerStats",
"commands": [
{
"name": "buyPotion",
"label": "HP Potion (50g)",
"commandType": "consumeResource",
"commandParameter": "gold",
"resourceAmount": 50
}
]
})
Quick Start Commands
Scene Setup
# Set up a 3D game scene (Camera + Light)
unity_scene_quickSetup({"setupType": "3D"})
# Set up a UI scene (Canvas + EventSystem)
unity_scene_quickSetup({"setupType": "UI"})
# Set up a 2D scene
unity_scene_quickSetup({"setupType": "2D"})
GameObject Creation
# Create from template (fastest way)
unity_gameobject_createFromTemplate({
"template": "Sphere", # Cube, Sphere, Player, Enemy, etc.
"name": "Ball",
"position": {"x": 0, "y": 5, "z": 0},
"scale": {"x": 0.5, "y": 0.5, "z": 0.5}
})
# Create hierarchical menu system
unity_menu_hierarchyCreate({
"menuName": "MainMenu",
"menuStructure": {
"Play": "Start Game",
"Settings": {
"text": "Game Settings",
"submenus": {
"Graphics": "Graphics Options",
"Audio": "Audio Settings"
}
},
"Quit": "Exit Game"
},
"generateStateMachine": True,
"stateMachineScriptPath": "Assets/Scripts/MenuManager.cs"
})
UI Creation
# Create button with one command
unity_ugui_createFromTemplate({
"template": "Button",
"text": "Start Game",
"width": 200,
"height": 50,
"anchorPreset": "middle-center"
})
# Create complete menu with navigation
unity_menu_hierarchyCreate({
"menuName": "GameMenu",
"menuStructure": {
"NewGame": "New Game",
"LoadGame": "Load Game",
"Options": {
"text": "Options",
"submenus": {
"Display": "Display Settings",
"Sound": "Sound Settings",
"Controls": "Control Settings"
}
},
"Exit": "Exit Game"
},
"generateStateMachine": True,
"stateMachineScriptPath": "Assets/Scripts/GameMenuManager.cs",
"buttonWidth": 250,
"buttonHeight": 60,
"navigationMode": "both"
})
Component Management
# Add component
unity_component_crud({
"operation": "add",
"gameObjectPath": "Player",
"componentType": "UnityEngine.Rigidbody"
})
# Update component properties
unity_component_crud({
"operation": "update",
"gameObjectPath": "Player",
"componentType": "UnityEngine.Transform",
"propertyChanges": {
"position": {"x": 0, "y": 1, "z": 0},
"rotation": {"x": 0, "y": 45, "z": 0}
}
})
# Fast inspection (existence check only)
unity_component_crud({
"operation": "inspect",
"gameObjectPath": "Player",
"componentType": "UnityEngine.CharacterController",
"includeProperties": False # 10x faster!
})
Scene Inspection
# Get scene overview (returns one level of hierarchy for performance)
unity_scene_crud({
"operation": "inspect",
"includeHierarchy": True,
"includeComponents": False, # Skip components for speed
"filter": "Player*" # Optional: filter by pattern
})
# For deeper exploration, inspect specific GameObject
unity_gameobject_crud({
"operation": "inspect",
"gameObjectPath": "Player/Weapon",
"includeComponents": True
})
Script Template Generation
# Generate MonoBehaviour template
unity_script_template_generate({
"templateType": "MonoBehaviour",
"className": "PlayerController",
"scriptPath": "Assets/Scripts/PlayerController.cs",
"namespace": "MyGame.Player"
})
# Generate ScriptableObject template
unity_script_template_generate({
"templateType": "ScriptableObject",
"className": "GameConfig",
"scriptPath": "Assets/ScriptableObjects/GameConfig.cs"
})
# Modify generated template using asset_crud
unity_asset_crud({
"operation": "update",
"assetPath": "Assets/Scripts/PlayerController.cs",
"content": "using UnityEngine;\n\nnamespace MyGame.Player\n{\n public class PlayerController : MonoBehaviour\n {\n public float speed = 5f;\n \n void Update()\n {\n // Movement code\n }\n }\n}"
})
Design Pattern Generation
# Generate Singleton pattern
unity_designPattern_generate({
"patternType": "singleton",
"className": "GameManager",
"scriptPath": "Assets/Scripts/GameManager.cs",
"options": {
"persistent": True,
"threadSafe": True,
"monoBehaviour": True
}
})
# Generate ObjectPool pattern
unity_designPattern_generate({
"patternType": "objectpool",
"className": "BulletPool",
"scriptPath": "Assets/Scripts/BulletPool.cs",
"options": {
"pooledType": "Bullet",
"defaultCapacity": "100",
"maxSize": "500"
}
})
# Generate StateMachine pattern
unity_designPattern_generate({
"patternType": "statemachine",
"className": "PlayerStateMachine",
"scriptPath": "Assets/Scripts/PlayerStateMachine.cs",
"namespace": "MyGame.Player"
})
# Available patterns: singleton, objectpool, statemachine, observer, command, factory, servicelocator
Best Practices
DO ✅
Use templates - 10x faster than manual creation
unity_ugui_createFromTemplate({"template": "Button"}) # Not manual GameObject + components
Check context first - Understand current state before changes
unity_context_inspect({"includeHierarchy": True, "includeComponents": False})
Use menu creation - Create complete menu systems with navigation
unity_menu_hierarchyCreate({"menuName": "MainMenu", "menuStructure": {...}}) # Not manual UI creation
Use script templates - Generate standard Unity script structures quickly
unity_script_template_generate({"templateType": "MonoBehaviour", "className": "Player", "scriptPath": "Assets/Scripts/Player.cs"})
Optimize inspections - Use includeProperties=false and propertyFilter
unity_component_crud({
"operation": "inspect",
"gameObjectPath": "Player",
"componentType": "UnityEngine.Transform",
"propertyFilter": ["position", "rotation"] # Only specific properties
})
Limit batch operations - Use maxResults to prevent timeouts
unity_component_crud({
"operation": "addMultiple",
"pattern": "Enemy*",
"componentType": "UnityEngine.Rigidbody",
"maxResults": 1000 # Safe limit
})
DON'T ❌
- Don't create UI manually - Use templates instead
- Don't edit .meta files - Unity manages these automatically
- Don't use asset tool for scripts - Use script batch manager
- Don't skip context inspection - Know what exists before modifying
- Don't use unlimited batch operations - Always set
maxResults
Component Type Reference
Common Unity Components
- Transform:
UnityEngine.Transform
- Rigidbody:
UnityEngine.Rigidbody
- Colliders:
UnityEngine.BoxCollider, UnityEngine.SphereCollider, UnityEngine.CapsuleCollider
- Renderer:
UnityEngine.MeshRenderer, UnityEngine.SpriteRenderer
- Camera:
UnityEngine.Camera
- Light:
UnityEngine.Light
- Audio:
UnityEngine.AudioSource, UnityEngine.AudioListener
UI Components (UGUI)
- Canvas:
UnityEngine.Canvas, UnityEngine.UI.CanvasScaler, UnityEngine.UI.GraphicRaycaster
- Controls:
UnityEngine.UI.Button, UnityEngine.UI.Toggle, UnityEngine.UI.Slider, UnityEngine.UI.InputField
- Display:
UnityEngine.UI.Text, UnityEngine.UI.Image, UnityEngine.UI.RawImage
- Layout:
UnityEngine.UI.VerticalLayoutGroup, UnityEngine.UI.HorizontalLayoutGroup, UnityEngine.UI.GridLayoutGroup
Performance Tips
Fast Operations
# ⚡ Ultra-fast: Check existence only (0.1s)
unity_component_crud({
"operation": "inspect",
"gameObjectPath": "Player",
"componentType": "UnityEngine.Rigidbody",
"includeProperties": False
})
# ⚡ Fast: Get specific properties (0.3s)
unity_component_crud({
"operation": "inspect",
"gameObjectPath": "Player",
"componentType": "UnityEngine.Transform",
"propertyFilter": ["position"]
})
Batch Operations with Safety
# Test small first
test = unity_component_crud({
"operation": "addMultiple",
"pattern": "Enemy*",
"componentType": "UnityEngine.Rigidbody",
"maxResults": 10, # Test with 10 first
"stopOnError": False
})
# If successful, scale up
if test["errorCount"] == 0:
unity_component_crud({...,"maxResults": 1000})
Common Workflows
Create a Main Menu
# 1. Setup UI scene
unity_scene_quickSetup({"setupType": "UI"})
# 2. Create complete menu system with navigation
unity_menu_hierarchyCreate({
"menuName": "MainMenu",
"menuStructure": {
"Play": "Start Game",
"Settings": {
"text": "Settings",
"submenus": {
"Graphics": "Graphics Settings",
"Audio": "Audio Settings",
"Controls": "Control Settings"
}
},
"Credits": "View Credits",
"Quit": "Exit Game"
},
"generateStateMachine": True,
"stateMachineScriptPath": "Assets/Scripts/MainMenuManager.cs",
"buttonWidth": 300,
"buttonHeight": 60,
"spacing": 15
})
Create a Game Level
# 1. Setup 3D scene
unity_scene_quickSetup({"setupType": "3D"})
# 2. Create player
unity_gameobject_createFromTemplate({
"template": "Player",
"position": {"x": 0, "y": 1, "z": 0}
})
# 3. Create ground
unity_gameobject_createFromTemplate({
"template": "Plane",
"name": "Ground",
"scale": {"x": 10, "y": 1, "z": 10}
})
# 4. Create obstacles
for i in range(5):
unity_gameobject_createFromTemplate({
"template": "Cube",
"name": f"Obstacle{i}",
"position": {"x": i*2, "y": 0.5, "z": 0}
})
Troubleshooting
Unity Bridge Not Connected
Solution: Open Unity → Tools → MCP Assistant → Start Bridge
GameObject Not Found
Solution: Use unity_context_inspect() to see what exists
Component Type Not Found
Solution: Use fully qualified names (e.g., UnityEngine.UI.Button, not just Button)
Operation Timeout
Solution:
- Use
includeProperties=false for faster operations
- Set
maxResults limit for batch operations
- Check Unity isn't compiling scripts
Complete Tool Reference
📚 For detailed documentation of all 28 tools, see TOOLS_REFERENCE.md
The tools are organized into 10 categories:
| Category |
Tools |
Description |
| Core Tools |
4 |
Connection, context, menu creation, compilation |
| Scene Management |
2 |
Scene CRUD, quick setup templates |
| GameObject Operations |
3 |
GameObject CRUD, templates, tag/layer management |
| Component Management |
1 |
Component CRUD with batch operations |
| Asset Management |
2 |
Asset operations, C# script batch management |
| Design Patterns |
1 |
Generate production-ready design pattern implementations |
| UI (UGUI) Tools |
6 |
UI templates, layouts, RectTransform, overlap detection |
| Prefab Management |
1 |
Prefab workflow (create, instantiate, apply/revert) |
| Advanced Features |
7 |
Settings, pipeline, input system, tilemap, navmesh, constants |
| Utility Tools |
1 |
Compilation waiting |
Total: 28 Tools
Quick Tool Reference
Scene Management
unity_scene_quickSetup - Quick scene setup (3D/2D/UI/VR)
unity_scene_crud - Create, load, save, delete scenes, manage build settings
unity_context_inspect - Get scene hierarchy and state
GameObject Operations
unity_gameobject_createFromTemplate - Create from templates
unity_gameobject_crud - Full GameObject CRUD operations
unity_menu_hierarchyCreate - Create hierarchical menu systems with navigation
Component Management
unity_component_crud - Add, update, remove, inspect components
UI Creation
unity_ugui_createFromTemplate - Create UI elements from templates
unity_ugui_layoutManage - Manage layout components
Asset & Script Management
unity_asset_crud - Asset file operations (including C# scripts)
unity_script_template_generate - Generate MonoBehaviour/ScriptableObject templates
Design Patterns
unity_designPattern_generate - Generate design pattern implementations (Singleton, ObjectPool, StateMachine, Observer, Command, Factory, ServiceLocator)
Advanced Features
unity_prefab_crud - Prefab workflow operations
unity_projectSettings_crud - Project settings management (player, quality, time, physics, audio, editor)
unity_renderPipeline_manage - Render pipeline configuration (Built-in, URP, HDRP)
unity_tagLayer_manage - Tag and layer management
unity_constant_convert - Convert between Unity constants and values (enums, colors, layers)
unity_template_manage - Customize GameObjects and convert to prefabs
UGUI Tools
unity_ugui_manage - Unified UGUI management (RectTransform operations)
unity_ugui_rectAdjust - Adjust RectTransform size
unity_ugui_anchorManage - Manage RectTransform anchors
unity_ugui_detectOverlaps - Detect overlapping UI elements
Utility
unity_ping - Test connection and get Unity version
unity_await_compilation - Wait for Unity compilation to complete (includes console logs in results)
Tips for Success
- Always check context before major operations - Know what you're working with
- Use templates whenever possible - They're optimized and reliable
- Batch similar operations - More efficient than individual commands
- Set appropriate timeouts - Some operations need more time (script compilation)
- Use property filters - Get only the data you need
- Test with small limits first - Before scaling up batch operations
- Follow Unity naming conventions - Use full component type names
Additional Documentation
GameKit Framework
📚 SKILL_GAMEKIT.md - Complete guide to GameKit framework:
- GameKitActor (player/NPC controllers)
- GameKitManager (resource/state/turn management)
- GameKitUICommand (UI → game logic bridge)
- GameKitMachinations (economic systems)
- GameKitSceneFlow (scene transitions)
- GameKitInteraction (trigger systems)
- Includes complete game examples (RPG, Tower Defense, Turn-Based Strategy)
MCP Tools Reference
📚 TOOLS_REFERENCE.md - Detailed documentation of all 28+ MCP tools
You now have complete control over Unity Editor. Build amazing projects! 🚀
1---2name: unityaiforge3description: AI-powered Unity development toolkit with Model Context Protocol integration4license: MIT5---6
7# Unity-AI-Forge - AI-Powered Unity Development
8
9**Forge Unity games through AI collaboration. Model Context Protocol integration with GameKit framework.**
10
11You are now working with Unity-AI-Forge, a powerful system that lets you create, modify, and manage Unity projects directly from this conversation through intelligent AI collaboration.
12
13## Prerequisites
14
15Before using these tools, ensure:
161. Unity Editor is open
172. MCP Bridge is started (Tools > MCP Assistant > Start Bridge)
183. Connection status shows "Connected"
19
20## Core Capabilities
21
22### 🎮 Scene Management
23- **Quick setup**: Instantly create 3D, 2D, UI, or VR scenes with proper configuration
24- **Scene operations**: Create, load, save, delete, and list scenes
25- **Context inspection**: Get real-time scene hierarchy and GameObject information
26
27### 🎨 GameObject Operations
28- **Templates**: Create common GameObjects (Cube, Sphere, Player, Enemy, etc.) with one command
29- **CRUD operations**: Create, rename, move, duplicate, delete GameObjects
30- **Batch operations**: Find and modify multiple GameObjects using patterns
31- **Hierarchy builder**: Build complex nested structures declaratively
32
33### 🧩 Component Management
34- **Add/Remove/Update**: Manage components on any GameObject
35- **Property setting**: Set component properties including asset references
36- **UnityEvent listeners**: Configure UI event handlers (Button.onClick, etc.)
37- **Batch operations**: Add/remove/update components on multiple GameObjects
38
39### 🖼️ UI Creation (UGUI)
40- **Templates**: Create complete UI elements (Button, Panel, ScrollView, Dropdown, etc.)
41- **Layout management**: Add and configure layout groups (Vertical, Horizontal, Grid)
42- **Anchor presets**: Position UI elements correctly on Canvas
43
44### 📦 Asset & Script Management
45- **Asset operations**: Rename, duplicate, delete, inspect assets and update importer settings
46- **Script template generation**: Generate MonoBehaviour and ScriptableObject templates with proper Unity structure
47- **Prefab workflow**: Create, instantiate, update, apply/revert prefab overrides
48- **Design patterns**: Generate production-ready implementations of common design patterns (Singleton, ObjectPool, StateMachine, Observer, Command, Factory, ServiceLocator)
49
50### 🎯 Advanced Features
51- **Project settings**: Read/write Unity project settings (player, quality, time, physics, audio, editor)
52- **Render pipeline**: Inspect and configure render pipeline settings (Built-in, URP, HDRP)
53- **Tags & Layers**: Manage project tags and layers, set on GameObjects
54- **Constants**: Convert between Unity constants and numeric values (enums, colors, layers)
55
56## 🎮 GameKit Framework
57
58**Unity-AI-Forge includes the GameKit framework - a high-level game development system with MCP integration.**
59
60GameKit provides:
61- **GameKitActor**: Player/NPC controllers with input abstraction
62- **GameKitManager**: Centralized game systems (resources, states, turns)
63- **GameKitUICommand**: Bridge UI buttons to game logic
64- **GameKitMachinations**: Economic systems with flows/converters/triggers
65- **GameKitSceneFlow**: State machine-based scene transitions
66- **GameKitInteraction**: Trigger-based game events
67
68**📚 See [SKILL_GAMEKIT.md](SKILL_GAMEKIT.md) for complete GameKit documentation with examples.**
69
70### Quick GameKit Examples
71
72```python
73# Create a player actor
74gamekitActor({
75 "operation": "create",
76 "actorId": "Player",
77 "controlMode": "directController",
78 "behaviorProfile": "3dCharacterController"
79})
80
81# Create a resource manager for RPG
82gamekitManager({
83 "operation": "create",
84 "managerId": "PlayerStats",
85 "managerType": "resourcepool",
86 "initialResources": {
87 "health": 100,
88 "mana": 50,
89 "gold": 0
90 }
91})
92
93# Create UI buttons that control resources
94gamekitUICommand({
95 "operation": "createCommandPanel",
96 "panelId": "ShopUI",
97 "canvasPath": "Canvas",
98 "targetType": "manager",
99 "targetManagerId": "PlayerStats",
100 "commands": [
101 {
102 "name": "buyPotion",
103 "label": "HP Potion (50g)",
104 "commandType": "consumeResource",
105 "commandParameter": "gold",
106 "resourceAmount": 50
107 }
108 ]
109})
110```
111
112---
113
114## Quick Start Commands
115
116### Scene Setup
117```python
118# Set up a 3D game scene (Camera + Light)
119unity_scene_quickSetup({"setupType": "3D"})
120
121# Set up a UI scene (Canvas + EventSystem)
122unity_scene_quickSetup({"setupType": "UI"})
123
124# Set up a 2D scene
125unity_scene_quickSetup({"setupType": "2D"})
126```
127
128### GameObject Creation
129```python
130# Create from template (fastest way)
131unity_gameobject_createFromTemplate({
132 "template": "Sphere", # Cube, Sphere, Player, Enemy, etc.
133 "name": "Ball",
134 "position": {"x": 0, "y": 5, "z": 0},
135 "scale": {"x": 0.5, "y": 0.5, "z": 0.5}
136})
137
138# Create hierarchical menu system
139unity_menu_hierarchyCreate({
140 "menuName": "MainMenu",
141 "menuStructure": {
142 "Play": "Start Game",
143 "Settings": {
144 "text": "Game Settings",
145 "submenus": {
146 "Graphics": "Graphics Options",
147 "Audio": "Audio Settings"
148 }
149 },
150 "Quit": "Exit Game"
151 },
152 "generateStateMachine": True,
153 "stateMachineScriptPath": "Assets/Scripts/MenuManager.cs"
154})
155```
156
157### UI Creation
158```python
159# Create button with one command
160unity_ugui_createFromTemplate({
161 "template": "Button",
162 "text": "Start Game",
163 "width": 200,
164 "height": 50,
165 "anchorPreset": "middle-center"
166})
167
168# Create complete menu with navigation
169unity_menu_hierarchyCreate({
170 "menuName": "GameMenu",
171 "menuStructure": {
172 "NewGame": "New Game",
173 "LoadGame": "Load Game",
174 "Options": {
175 "text": "Options",
176 "submenus": {
177 "Display": "Display Settings",
178 "Sound": "Sound Settings",
179 "Controls": "Control Settings"
180 }
181 },
182 "Exit": "Exit Game"
183 },
184 "generateStateMachine": True,
185 "stateMachineScriptPath": "Assets/Scripts/GameMenuManager.cs",
186 "buttonWidth": 250,
187 "buttonHeight": 60,
188 "navigationMode": "both"
189})
190```
191
192### Component Management
193```python
194# Add component
195unity_component_crud({
196 "operation": "add",
197 "gameObjectPath": "Player",
198 "componentType": "UnityEngine.Rigidbody"
199})
200
201# Update component properties
202unity_component_crud({
203 "operation": "update",
204 "gameObjectPath": "Player",
205 "componentType": "UnityEngine.Transform",
206 "propertyChanges": {
207 "position": {"x": 0, "y": 1, "z": 0},
208 "rotation": {"x": 0, "y": 45, "z": 0}
209 }
210})
211
212# Fast inspection (existence check only)
213unity_component_crud({
214 "operation": "inspect",
215 "gameObjectPath": "Player",
216 "componentType": "UnityEngine.CharacterController",
217 "includeProperties": False # 10x faster!
218})
219```
220
221### Scene Inspection
222```python
223# Get scene overview (returns one level of hierarchy for performance)
224unity_scene_crud({
225 "operation": "inspect",
226 "includeHierarchy": True,
227 "includeComponents": False, # Skip components for speed
228 "filter": "Player*" # Optional: filter by pattern
229})
230
231# For deeper exploration, inspect specific GameObject
232unity_gameobject_crud({
233 "operation": "inspect",
234 "gameObjectPath": "Player/Weapon",
235 "includeComponents": True
236})
237```
238
239### Script Template Generation
240```python
241# Generate MonoBehaviour template
242unity_script_template_generate({
243 "templateType": "MonoBehaviour",
244 "className": "PlayerController",
245 "scriptPath": "Assets/Scripts/PlayerController.cs",
246 "namespace": "MyGame.Player"
247})
248
249# Generate ScriptableObject template
250unity_script_template_generate({
251 "templateType": "ScriptableObject",
252 "className": "GameConfig",
253 "scriptPath": "Assets/ScriptableObjects/GameConfig.cs"
254})
255
256# Modify generated template using asset_crud
257unity_asset_crud({
258 "operation": "update",
259 "assetPath": "Assets/Scripts/PlayerController.cs",
260 "content": "using UnityEngine;\n\nnamespace MyGame.Player\n{\n public class PlayerController : MonoBehaviour\n {\n public float speed = 5f;\n \n void Update()\n {\n // Movement code\n }\n }\n}"
261})
262```
263
264### Design Pattern Generation
265```python
266# Generate Singleton pattern
267unity_designPattern_generate({
268 "patternType": "singleton",
269 "className": "GameManager",
270 "scriptPath": "Assets/Scripts/GameManager.cs",
271 "options": {
272 "persistent": True,
273 "threadSafe": True,
274 "monoBehaviour": True
275 }
276})
277
278# Generate ObjectPool pattern
279unity_designPattern_generate({
280 "patternType": "objectpool",
281 "className": "BulletPool",
282 "scriptPath": "Assets/Scripts/BulletPool.cs",
283 "options": {
284 "pooledType": "Bullet",
285 "defaultCapacity": "100",
286 "maxSize": "500"
287 }
288})
289
290# Generate StateMachine pattern
291unity_designPattern_generate({
292 "patternType": "statemachine",
293 "className": "PlayerStateMachine",
294 "scriptPath": "Assets/Scripts/PlayerStateMachine.cs",
295 "namespace": "MyGame.Player"
296})
297
298# Available patterns: singleton, objectpool, statemachine, observer, command, factory, servicelocator
299```
300
301## Best Practices
302
303### DO ✅
3041. **Use templates** - 10x faster than manual creation
305 ```python
306 unity_ugui_createFromTemplate({"template": "Button"}) # Not manual GameObject + components
307 ```
308
3092. **Check context first** - Understand current state before changes
310 ```python
311 unity_context_inspect({"includeHierarchy": True, "includeComponents": False})
312 ```
313
3143. **Use menu creation** - Create complete menu systems with navigation
315 ```python
316 unity_menu_hierarchyCreate({"menuName": "MainMenu", "menuStructure": {...}}) # Not manual UI creation
317 ```
318
3194. **Use script templates** - Generate standard Unity script structures quickly
320 ```python
321 unity_script_template_generate({"templateType": "MonoBehaviour", "className": "Player", "scriptPath": "Assets/Scripts/Player.cs"})
322 ```
323
3245. **Optimize inspections** - Use `includeProperties=false` and `propertyFilter`
325 ```python
326 unity_component_crud({
327 "operation": "inspect",
328 "gameObjectPath": "Player",
329 "componentType": "UnityEngine.Transform",
330 "propertyFilter": ["position", "rotation"] # Only specific properties
331 })
332 ```
333
3346. **Limit batch operations** - Use `maxResults` to prevent timeouts
335 ```python
336 unity_component_crud({
337 "operation": "addMultiple",
338 "pattern": "Enemy*",
339 "componentType": "UnityEngine.Rigidbody",
340 "maxResults": 1000 # Safe limit
341 })
342 ```
343
344### DON'T ❌
3451. **Don't create UI manually** - Use templates instead
3462. **Don't edit .meta files** - Unity manages these automatically
3473. **Don't use asset tool for scripts** - Use script batch manager
3484. **Don't skip context inspection** - Know what exists before modifying
3495. **Don't use unlimited batch operations** - Always set `maxResults`
350
351## Component Type Reference
352
353### Common Unity Components
354- Transform: `UnityEngine.Transform`
355- Rigidbody: `UnityEngine.Rigidbody`
356- Colliders: `UnityEngine.BoxCollider`, `UnityEngine.SphereCollider`, `UnityEngine.CapsuleCollider`
357- Renderer: `UnityEngine.MeshRenderer`, `UnityEngine.SpriteRenderer`
358- Camera: `UnityEngine.Camera`
359- Light: `UnityEngine.Light`
360- Audio: `UnityEngine.AudioSource`, `UnityEngine.AudioListener`
361
362### UI Components (UGUI)
363- Canvas: `UnityEngine.Canvas`, `UnityEngine.UI.CanvasScaler`, `UnityEngine.UI.GraphicRaycaster`
364- Controls: `UnityEngine.UI.Button`, `UnityEngine.UI.Toggle`, `UnityEngine.UI.Slider`, `UnityEngine.UI.InputField`
365- Display: `UnityEngine.UI.Text`, `UnityEngine.UI.Image`, `UnityEngine.UI.RawImage`
366- Layout: `UnityEngine.UI.VerticalLayoutGroup`, `UnityEngine.UI.HorizontalLayoutGroup`, `UnityEngine.UI.GridLayoutGroup`
367
368## Performance Tips
369
370### Fast Operations
371```python
372# ⚡ Ultra-fast: Check existence only (0.1s)
373unity_component_crud({
374 "operation": "inspect",
375 "gameObjectPath": "Player",
376 "componentType": "UnityEngine.Rigidbody",
377 "includeProperties": False
378})
379
380# ⚡ Fast: Get specific properties (0.3s)
381unity_component_crud({
382 "operation": "inspect",
383 "gameObjectPath": "Player",
384 "componentType": "UnityEngine.Transform",
385 "propertyFilter": ["position"]
386})
387```
388
389### Batch Operations with Safety
390```python
391# Test small first
392test = unity_component_crud({
393 "operation": "addMultiple",
394 "pattern": "Enemy*",
395 "componentType": "UnityEngine.Rigidbody",
396 "maxResults": 10, # Test with 10 first
397 "stopOnError": False
398})
399
400# If successful, scale up
401if test["errorCount"] == 0:
402 unity_component_crud({...,"maxResults": 1000})
403```
404
405## Common Workflows
406
407### Create a Main Menu
408```python
409# 1. Setup UI scene
410unity_scene_quickSetup({"setupType": "UI"})
411
412# 2. Create complete menu system with navigation
413unity_menu_hierarchyCreate({
414 "menuName": "MainMenu",
415 "menuStructure": {
416 "Play": "Start Game",
417 "Settings": {
418 "text": "Settings",
419 "submenus": {
420 "Graphics": "Graphics Settings",
421 "Audio": "Audio Settings",
422 "Controls": "Control Settings"
423 }
424 },
425 "Credits": "View Credits",
426 "Quit": "Exit Game"
427 },
428 "generateStateMachine": True,
429 "stateMachineScriptPath": "Assets/Scripts/MainMenuManager.cs",
430 "buttonWidth": 300,
431 "buttonHeight": 60,
432 "spacing": 15
433})
434```
435
436### Create a Game Level
437```python
438# 1. Setup 3D scene
439unity_scene_quickSetup({"setupType": "3D"})
440
441# 2. Create player
442unity_gameobject_createFromTemplate({
443 "template": "Player",
444 "position": {"x": 0, "y": 1, "z": 0}
445})
446
447# 3. Create ground
448unity_gameobject_createFromTemplate({
449 "template": "Plane",
450 "name": "Ground",
451 "scale": {"x": 10, "y": 1, "z": 10}
452})
453
454# 4. Create obstacles
455for i in range(5):
456 unity_gameobject_createFromTemplate({
457 "template": "Cube",
458 "name": f"Obstacle{i}",
459 "position": {"x": i*2, "y": 0.5, "z": 0}
460 })
461```
462
463## Troubleshooting
464
465### Unity Bridge Not Connected
466**Solution**: Open Unity → Tools → MCP Assistant → Start Bridge
467
468### GameObject Not Found
469**Solution**: Use `unity_context_inspect()` to see what exists
470
471### Component Type Not Found
472**Solution**: Use fully qualified names (e.g., `UnityEngine.UI.Button`, not just `Button`)
473
474### Operation Timeout
475**Solution**:
476- Use `includeProperties=false` for faster operations
477- Set `maxResults` limit for batch operations
478- Check Unity isn't compiling scripts
479
480## Complete Tool Reference
481
482**📚 For detailed documentation of all 28 tools, see [TOOLS_REFERENCE.md](docs/TOOLS_REFERENCE.md)**
483
484The tools are organized into 10 categories:
485
486| Category | Tools | Description |
487|----------|-------|-------------|
488| **Core Tools** | 4 | Connection, context, menu creation, compilation |
489| **Scene Management** | 2 | Scene CRUD, quick setup templates |
490| **GameObject Operations** | 3 | GameObject CRUD, templates, tag/layer management |
491| **Component Management** | 1 | Component CRUD with batch operations |
492| **Asset Management** | 2 | Asset operations, C# script batch management |
493| **Design Patterns** | 1 | Generate production-ready design pattern implementations |
494| **UI (UGUI) Tools** | 6 | UI templates, layouts, RectTransform, overlap detection |
495| **Prefab Management** | 1 | Prefab workflow (create, instantiate, apply/revert) |
496| **Advanced Features** | 7 | Settings, pipeline, input system, tilemap, navmesh, constants |
497| **Utility Tools** | 1 | Compilation waiting |
498
499**Total: 28 Tools**
500
501---
502
503## Quick Tool Reference
504
505### Scene Management
506- `unity_scene_quickSetup` - Quick scene setup (3D/2D/UI/VR)
507- `unity_scene_crud` - Create, load, save, delete scenes, manage build settings
508- `unity_context_inspect` - Get scene hierarchy and state
509
510### GameObject Operations
511- `unity_gameobject_createFromTemplate` - Create from templates
512- `unity_gameobject_crud` - Full GameObject CRUD operations
513- `unity_menu_hierarchyCreate` - Create hierarchical menu systems with navigation
514
515### Component Management
516- `unity_component_crud` - Add, update, remove, inspect components
517
518### UI Creation
519- `unity_ugui_createFromTemplate` - Create UI elements from templates
520- `unity_ugui_layoutManage` - Manage layout components
521
522### Asset & Script Management
523- `unity_asset_crud` - Asset file operations (including C# scripts)
524- `unity_script_template_generate` - Generate MonoBehaviour/ScriptableObject templates
525
526### Design Patterns
527- `unity_designPattern_generate` - Generate design pattern implementations (Singleton, ObjectPool, StateMachine, Observer, Command, Factory, ServiceLocator)
528
529### Advanced Features
530- `unity_prefab_crud` - Prefab workflow operations
531- `unity_projectSettings_crud` - Project settings management (player, quality, time, physics, audio, editor)
532- `unity_renderPipeline_manage` - Render pipeline configuration (Built-in, URP, HDRP)
533- `unity_tagLayer_manage` - Tag and layer management
534- `unity_constant_convert` - Convert between Unity constants and values (enums, colors, layers)
535- `unity_template_manage` - Customize GameObjects and convert to prefabs
536
537### UGUI Tools
538- `unity_ugui_manage` - Unified UGUI management (RectTransform operations)
539- `unity_ugui_rectAdjust` - Adjust RectTransform size
540- `unity_ugui_anchorManage` - Manage RectTransform anchors
541- `unity_ugui_detectOverlaps` - Detect overlapping UI elements
542
543### Utility
544- `unity_ping` - Test connection and get Unity version
545- `unity_await_compilation` - Wait for Unity compilation to complete (includes console logs in results)
546
547## Tips for Success
548
5491. **Always check context before major operations** - Know what you're working with
5502. **Use templates whenever possible** - They're optimized and reliable
5513. **Batch similar operations** - More efficient than individual commands
5524. **Set appropriate timeouts** - Some operations need more time (script compilation)
5535. **Use property filters** - Get only the data you need
5546. **Test with small limits first** - Before scaling up batch operations
5557. **Follow Unity naming conventions** - Use full component type names
556
557---
558
559## Additional Documentation
560
561### GameKit Framework
562**📚 [SKILL_GAMEKIT.md](SKILL_GAMEKIT.md)** - Complete guide to GameKit framework:
563- GameKitActor (player/NPC controllers)
564- GameKitManager (resource/state/turn management)
565- GameKitUICommand (UI → game logic bridge)
566- GameKitMachinations (economic systems)
567- GameKitSceneFlow (scene transitions)
568- GameKitInteraction (trigger systems)
569- **Includes complete game examples** (RPG, Tower Defense, Turn-Based Strategy)
570
571### MCP Tools Reference
572**📚 [TOOLS_REFERENCE.md](docs/TOOLS_REFERENCE.md)** - Detailed documentation of all 28+ MCP tools
573
574---
575
576**You now have complete control over Unity Editor. Build amazing projects!** 🚀