Skip to main content

manage_components

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_components

Description

Add, remove, or set properties on components attached to GameObjects. Actions: add, remove, set_property. Requires target (instance ID or name) and component_type. For READING component data, use the mcpforunity://scene/gameobject/{id}/components resource or mcpforunity://scene/gameobject/{id}/component/{name} for a single component. For creating/deleting GameObjects themselves, use manage_gameobject instead.

Parameters

NameTypeRequiredDescription
actionLiteral['add', 'remove', 'set_property']yesAction to perform: add (add component), remove (remove component), set_property (set component property)
targetstr | intyesTarget GameObject - instance ID (preferred) or name/path
component_typestryesComponent type name (e.g., 'Rigidbody', 'BoxCollider', 'MyScript')
search_methodLiteral['by_id', 'by_name', 'by_path'] | NoneHow to find the target GameObject
propertystr | NoneProperty name to set (for set_property action)
valuestr | int | float | bool | dict[Any] | list[Any] | NoneValue to set (for set_property action). For object references: instance ID (int), asset path (string), or {"guid": "..."} / {"path": "..."}. For Sprite sub-assets: {"guid": "...", "spriteName": ""} or {"guid": "...", "fileID": }. Single-sprite textures auto-resolve.
propertiesdict[str, Any] | str | NoneDictionary of property names to values. Example: {"mass": 5.0, "useGravity": false}
component_indexint | NoneZero-based index to select which component when multiple of the same type exist. Use the components resource to discover indices. If omitted, targets the first instance.

Returns

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

Examples

No examples yet. Add usage examples here — they will be preserved across regenerations.