Attach Script to GameObject
unity_attach_scriptAttach a MonoBehaviour script to a GameObject in Unity Editor with undo support. Requires compiled script; fails with a hint if class is missing.
Instructions
Attach a MonoBehaviour class to a GameObject (Undo-able). Script must be compiled — no compile errors in console.
Args: object_path ('Player'), script_class ('PlayerController'). Fails with hint if the class is not found (typo? not compiled yet?) — read the error.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"object_path": "<object_path>",
"script_class": "<script_class>"
},
"name": "unity_attach_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_path | Yes | Hierarchy path of the GameObject, e.g. 'Player' | |
| script_class | Yes | MonoBehaviour class name to attach, e.g. 'PlayerController' |