tea-x-random/unity-game-skills/unity-mcp-skill

Claude Code and agent skill by tea-x-random/unity-game-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Orchestrate Unity Editor via MCP (Model Context Protocol) tools and resources. Use when working with Unity projects through MCP for Unity - creating/modifying GameObjects, editing scripts, managing scenes, running tests, or any Unity Editor automation. Provides best practices, tool schemas, and workflow patterns for effective Unity-MCP integration.

Install

npx vskill@latest install tea-x-random/unity-game-skills/unity-mcp-skill

SKILL.md

The same SKILL.md was published earlier as tea-x-random/unity-game-skills/unity-mcp-skill.

Unity-MCP Operator Guide

This skill helps you effectively use the Unity Editor with MCP tools and resources.

Template Notice

Examples in references/workflows.md and references/tools-reference.md are reusable templates. They may be inaccurate across Unity versions, package setups (UGUI/TMP/Input System), and project-specific conventions. Please check console, compilation errors, or use screenshot after implementation.

Before applying a template:

  • Validate targets/components first via resources and find_gameobjects.
  • Treat names, enum values, and property payloads as placeholders to adapt.

Quick Start: Resource-First Workflow

Always read relevant resources before using tools. This prevents errors and provides the necessary context.

1. Check editor state → mcpforunity://editor/state
2. Understand the scene → mcpforunity://scene/gameobject-api
3. Find what you need → find_gameobjects or resources
4. Take action → tools (manage_gameobject, create_script, script_apply_edits, apply_text_edits, validate_script, delete_script, get_sha, etc.)
5. Verify results → read_console, manage_camera(action="screenshot"), resources

Critical Best Practices

1. After Writing/Editing Scripts: Wait for Compilation and Check Console
python
# After create_script or script_apply_edits:
# Both tools already trigger AssetDatabase.ImportAsset + RequestScriptCompilation automatically.
# No need to call refresh_unity — just wait for compilation to finish, then check console.
# 1. Poll editor state until compilation completes
# Read mcpforunity://editor/state → wait until is_compiling == false
# 2. Check for compilation errors
read_console(types=["error"], count=10, include_stacktrace=True)

Why: Unity must compile scripts before they're usable. create_script and script_apply_edits already trigger import and compilation automatically — calling refresh_unity afterward is redundant. Do not use a freshly-added type before `is_compiling == false` and the console is clean — it silently fails or throws. If you edited via plain file write (not create_script/script_apply_edits), kick the compile yourself: refresh_unity(mode="force", scope="scripts", compile="request", wait_for_ready=True), then poll.

1a. execute_code Is a C# 6 Method Body (CodeDom), Not a Sandbox

execute_code compiles a C# 6 method body via CodeDom when compiler="auto" (the default) and Roslyn (Microsoft.CodeAnalysis) is not installed. It is real C# — System.DateTime.Now and the like work — but the CodeDom path means:

  • No `using` directives, no local functions, no C#7+ syntax. Use fully-qualified type names (e.g. UnityEditor.EditorApplication.isCompiling).
  • Build multi-line output with System.Text.StringBuilder and return a value to read it back.
  • Pass compiler="roslyn" only when Roslyn is actually present.
python
execute_code(code='''
var sb = new System.Text.StringBuilder();
sb.AppendLine("compiling=" + UnityEditor.EditorApplication.isCompiling);
return sb.ToString();
''')
2. Use batch_execute for Multiple Operations
python
# 10-100x faster than sequential calls
batch_execute(
commands=[
{"tool": "manage_gameobject", "params": {"action": "create", "name": "Cube1", "primitive_type": "Cube"}},
{"tool": "manage_gameobject", "params": {"action": "create", "name": "Cube2", "primitive_type": "Cube"}},
{"tool": "manage_gameobject", "params": {"action": "create", "name": "Cube3", "primitive_type": "Cube"}}
],
parallel=True # Hint only: Unity may still execute sequentially
)

Max 25 commands per batch by default (configurable in Unity MCP Tools window, max 100). Use fail_fast=True for dependent operations.

Tip: Also use batch_execute for discovery — batch multiple find_gameobjects calls instead of calling them one at a time:

python
batch_execute(commands=[
{"tool": "find_gameobjects", "params": {"search_term": "Camera", "search_method": "by_component"}},
{"tool": "find_gameobjects", "params": {"search_term": "Player", "search_method": "by_tag"}},
{"tool": "find_gameobjects", "params": {"search_term": "GameManager", "search_method": "by_name"}}
])
3. Use Screenshots to Verify Visual Results
python
# Basic screenshot (saves to Assets/, returns file path only)
manage_camera(action="screenshot")
# Inline screenshot (returns base64 PNG directly to the AI)
manage_camera(action="screenshot", include_image=True)
# Use a specific camera and cap resolution for smaller payloads
manage_camera(action="screenshot", camera="MainCamera", include_image=True, max_resolution=512)
# Batch surround: captures front/back/left/right/top/bird_eye around the scene
manage_camera(action="screenshot", batch="surround", max_resolution=256)
# Batch surround centered on a specific object
manage_camera(action="screenshot", batch="surround", view_target="Player", max_resolution=256)
# Positioned screenshot: place a temp camera and capture in one call
manage_camera(action="screenshot", view_target="Player", view_position=[0, 10, -10], max_resolution=512)
# Scene View screenshot: capture what the developer sees in the editor
manage_camera(action="screenshot", capture_source="scene_view", include_image=True)
# Scene View framed on a specific object
manage_camera(action="screenshot", capture_source="scene_view", view_target="Canvas", include_image=True)

Best practices for AI scene understanding:

  • Use include_image=True when you need to see the scene, not just save a file.
  • Use batch="surround" for a comprehensive overview (6 angles, one command).
  • Use view_target/view_position to capture from a specific viewpoint without needing a scene camera.
  • Use capture_source="scene_view" to see the editor viewport (gizmos, wireframes, grid).
  • Keep max_resolution at 256–512 to balance quality vs. token cost.
python
# Agentic camera loop: point, shoot, analyze
manage_gameobject(action="look_at", target="MainCamera", look_at_target="Player")
manage_camera(action="screenshot", camera="MainCamera", include_image=True, max_resolution=512)
# → Analyze image, decide next action
# Multi-view screenshot (6-angle contact sheet)
manage_camera(action="screenshot_multiview", max_resolution=480)
# Scene View for editor-level inspection (shows gizmos, debug overlays, etc.)
manage_camera(action="screenshot", capture_source="scene_view", view_target="Player", include_image=True)

Portrait iPhone framing of Screen-Space-Overlay UI. Screenshots capture at the Game view's current size; there is no MCP param to force portrait. Add and select a portrait FixedResolution size via execute_code + reflection (these UnityEditor types are internal):

  1. GameViewSizes ScriptableSingleton → .currentGroup → AddCustomSize(new GameViewSize(GameViewSizeType.FixedResolution, w, h, label)).
  2. On the GameView window call the private SizeSelectionCallback(index, null), then Repaint().
  3. manage_camera(action="screenshot") with no `camera` arg (ScreenCapture API path) now grabs overlay UI at that resolution.

Common portrait sizes: 1170x2532 (iPhone 12/13/14), 1080x1920.

4. Check Console After Major Changes
python
read_console(
action="get",
types=["error", "warning"], # Focus on problems
count=10,
format="detailed"
)
5. Always Check editor_state Before Complex Operations
python
# Read mcpforunity://editor/state to check:
# - is_compiling: Wait if true
# - is_domain_reload_pending: Wait if true
# - ready_for_tools: Only proceed if true
# - blocking_reasons: Why tools might fail

Parameter Type Conventions

These are common patterns, not strict guarantees. manage_components.set_property payload shapes can vary by component/property; if a template fails, inspect the component resource payload and adjust.

Vectors (position, rotation, scale, color)
python
# Both forms accepted:
position=[1.0, 2.0, 3.0] # List
position="[1.0, 2.0, 3.0]" # JSON string
Booleans
python
# Both forms accepted:
include_inactive=True # Boolean
include_inactive="true" # String
Colors
python
# Auto-detected format:
color=[255, 0, 0, 255] # 0-255 range
color=[1.0, 0.0, 0.0, 1.0] # 0.0-1.0 normalized (auto-converted)
Paths
python
# Assets-relative (default):
path="Assets/Scripts/MyScript.cs"
# URI forms:
uri="mcpforunity://path/Assets/Scripts/MyScript.cs"
uri="file:///full/path/to/file.cs"

Core Tool Categories

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
3
7-day trend score
7

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/tea-x-random/unity-game-skills/unity-mcp-skill/badge)](https://verified-skill.com/skills/tea-x-random/unity-game-skills/unity-mcp-skill)

Something wrong with this skill or its page? Tell us.