| paths |
|
|---|
When Unity Editor is connected via UnityMCP, prefer MCP tools over file operations.
- DO NOT use
create_scriptfor new.csfiles — justWrite, put all required content andrefresh_unity - To modify existing
.csfiles: DO NOT useEdit, just modify file andrefresh_unity Editrequires reading the file first (Read) before it will accept edits- Path is project-relative:
Assets/Scripts/[Feature]/ClassName.cs - After any script create or edit, call
read_console(types=["error"])before proceeding — it correctly surfaces compilation errors afterrefresh_unity - Poll
mcpforunity://editor/state→is_compilingif compilation may still be in progress
- No MCP tool for
.asmdef— write viaWritetool, then callrefresh_unityto trigger import - Follow
.claude/rules/unity/asmdef.mdfor format
- Create flow:
manage_gameobject(create)→manage_components(add)→manage_prefabs(create_from_gameobject, prefab_path=...) create_from_gameobjectalso links the scene instance to the new prefab automatically- Instantiate in scene:
manage_gameobject(action=create, prefab_path=...) - Edit fields:
manage_components(set_property) - Create variant:
manage_prefabs(create_variant)
- Inspect:
manage_scene(get_hierarchy) - Add/remove/modify objects:
manage_gameobject,manage_components - Always save after changes:
manage_scene(save) - Scene build registration has no MCP tool — edit
ProjectSettings/EditorBuildSettings.assetdirectly
- After a domain reload, numeric instance IDs can go stale — prefer targeting by name string
- Use
find_gameobjectsto resolve current instance IDs when needed - Pay extra attention to setup references - when some prefab instance parts are used in prefab/scene context, use references to instance parts, not prefab parts
- "Bridge is not running" and "WebSocket is not initialised" are benign — HTTP transport works fine
Never enter Play mode (manage_editor(action="play")) or use execute_code to simulate input (synthetic PointerDownEvent/PointerUpEvent dispatch, reflection-driven clicks, etc.) to verify a bug fix, unless the user directly asks for that. Synthetic input is an unreliable proxy for real interaction — it's easy to get isPrimary/coordinate-space/event-queue-flushing details subtly wrong and get a misleading pass/fail signal that doesn't match what happens when the user actually plays.
What's fine and expected as a normal edit-verify step:
refresh_unity+read_console(types=["error"])to confirm a change compiles — this is not a Play mode test.- Adding targeted
Debug.Logcalls at a suspect code path to help diagnose an issue.
What to avoid unless explicitly asked:
manage_editor(action="play")to reproduce or confirm a bug/fix.execute_codecalls that poke at live GameObjects/UI state to "confirm" behavior, or that construct/dispatch synthetic input events.
After a change, describe what changed and ask the user to try it in Play mode themselves; only pull read_console logs afterward once they've triggered the scenario. If the user explicitly asks for Play mode testing or a specific simulated input, that overrides this default for that request only.