Skip to main content

gameobject_duplicate

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: scene  ·  Module: services.registry.capability_adapter

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

Description​

Duplicate a GameObject with optional name, parent and position changes.

Parameters​

NameTypeRequiredDescription
actionLiteral['duplicate']yesFeature action to perform.
targetstr | None—GameObject identifier by name, path, or instance ID for modify/delete/duplicate actions
search_methodLiteral['by_id', 'by_name', 'by_path', 'by_tag', 'by_layer', 'by_component'] | None—How to resolve 'target'. If omitted, Unity infers: instance ID -> by_id, path (contains '/') -> by_path, otherwise by_name. Delete removes all matches, including inactive objects; use by_id with a current instance ID to delete one object.
namestr | None—GameObject name for 'create' (initial name) and 'modify' (rename) actions.
parentstr | None—Parent GameObject reference - used for both 'create' (initial parent) and 'modify' (change parent)
positionlist[float] | dict[str, float] | str | None—Position as [x, y, z] array, {x, y, z} object, or JSON string
new_namestr | None—New name for the duplicated object (default: SourceName_Copy)
offsetlist[float] | str | None—Offset from original/reference position as [x, y, z] array (list or JSON string)
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​

Duplicate a scene marker, give the copy a new name, and offset it by two units on X. Use the unique name or current instance ID of the source object.

MCP arguments
{
"action": "duplicate",
"target": "Prototype Marker",
"search_method": "by_name",
"new_name": "Prototype Marker B",
"offset": [
2,
0,
0
]
}