Skip to main content

manage_object_handles

Auto-generated from the Python tool registry. Do not hand-edit outside <!-- examples:start --><!-- examples:end --> blocks — the generator (tools/generate_docs_reference.py) will overwrite them.

Group: core  ·  Module: services.tools.manage_object_handles

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Capture or resolve the original loaded GameObject/Component reference for this Editor session. Capture accepts only a nonzero live instance_id; resolve accepts only handle. All handles, including clean saved scenes, expire after 600 seconds or earlier eviction from a 512-entry weak cache. Scene close/open/new-scene events, domain reload/Editor restart, every Play transition and Undo/Redo expire all handles. Direct rename, property edits, same-scene reparenting and save retain the original reference. Resolution requires its original loaded owner/scene/prefab-stage context; observed context mismatch is final. An unobserved scene move and return may retain the same original reference. Current prefab-stage and runtime scene objects are supported; persistent asset objects are not. Never loads assets/scenes, saves, scans or falls back to serialized IDs, names or paths. require_persistent and allow_asset_load are unsupported, including false: omit both. On stale_handle rediscover explicitly and capture again. Requires v2 Editor commands; older Editors fail closed. The descriptor includes the original scene's current path (null above 512 UTF-16 units) and session-local native handle. Returned instance IDs remain ephemeral; no reload retry.

Parameters​

NameTypeRequiredDescription
actionLiteral['capture', 'resolve']yes
instance_idint—
handlestr—
require_persistentbool—Unsupported legacy field: omit entirely. Any presence, including false, fails.
allow_asset_loadbool—Unsupported legacy field: omit entirely. Any presence, including false, fails.
unity_instancestr | int | None—Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance.

Returns​

A dict containing the Unity response. The exact shape depends on the action.

Examples​

Capture a handle for a specific, currently loaded object. Replace the integer with the instance ID from a fresh GameObject or component lookup. Keep the returned handle for resolve in the same Editor session.

MCP arguments
{
"action": "capture",
"instance_id": 43210
}