--- name: cinemachine-modify description: "Generic write: apply a `SerializedMember` diff to any Cinemachine `Component` on a GameObject via ReflectorNet `TryModify`. Use 'cinemachine-get' first to inspect the structure so the diff is targeted." metadata: generated-by: mcp-plugin-dotnet --- # Cinemachine / Modify Component Modify any Cinemachine component on a GameObject by applying a `SerializedMember` diff via ReflectorNet. This is the generic escape hatch for fields not covered by the dedicated tools. ## Inputs - `gameObjectRef` — the GameObject hosting the component (required). - `componentRef` — optional. Resolves a specific component when the GameObject has more than one Cinemachine component; otherwise the first component in the `Unity.Cinemachine` namespace is used. - `data` — the `SerializedMember` diff to apply. Include only the properties you want to change. ## Behavior Finds the target Cinemachine component, applies the diff via `Reflector.TryModify`, and on success marks the component + scene dirty and repaints. The applied logs are returned. Runs on the Unity main thread. ## How to Call ```bash unity-mcp-cli run-tool cinemachine-modify --input '{ "gameObjectRef": "string_value", "data": "string_value", "componentRef": "string_value" }' ``` > For complex input (multi-line strings, code), save the JSON to a file and use: > ```bash > unity-mcp-cli run-tool cinemachine-modify --input-file args.json > ``` > > Or pipe via stdin (recommended): > ```bash > unity-mcp-cli run-tool cinemachine-modify --input-file - <<'EOF' > {"param": "value"} > EOF > ``` ### Troubleshooting If `unity-mcp-cli` is not found, either install it globally (`npm install -g unity-mcp-cli`) or use `npx unity-mcp-cli` instead. Read the /unity-initial-setup skill for detailed installation instructions. ## Input | Name | Type | Required | Description | |------|------|----------|-------------| | `gameObjectRef` | `any` | Yes | Reference to the GameObject containing the Cinemachine component. | | `data` | `any` | Yes | The SerializedMember diff to apply. Only include properties you want to change. | | `componentRef` | `any` | No | Optional reference to a specific Cinemachine component if the GameObject has multiple. | ### Input JSON Schema ```json { "type": "object", "properties": { "gameObjectRef": { "$ref": "#/$defs/AIGD.GameObjectRef" }, "data": { "$ref": "#/$defs/com.IvanMurzak.ReflectorNet.Model.SerializedMember" }, "componentRef": { "$ref": "#/$defs/AIGD.ComponentRef" } }, "$defs": { "UnityEngine.EntityId": { "type": "string", "pattern": "^[0-9]+$" }, "System.Type": { "type": "string" }, "AIGD.GameObjectRef": { "type": "object", "properties": { "instanceID": { "$ref": "#/$defs/UnityEngine.EntityId", "description": "instanceID of the UnityEngine.Object. If it is '0' and 'path', 'name', 'assetPath' and 'assetGuid' is not provided, empty or null, then it will be used as 'null'. Priority: 1 (Recommended)" }, "path": { "type": "string", "description": "Path of a GameObject in the hierarchy Sample 'character/hand/finger/particle'. Priority: 2." }, "name": { "type": "string", "description": "Name of a GameObject in hierarchy. Priority: 3." }, "assetType": { "$ref": "#/$defs/System.Type", "description": "Type of the asset." }, "assetPath": { "type": "string", "description": "Path to the asset within the project. Starts with 'Assets/'" }, "assetGuid": { "type": "string", "description": "Unique identifier for the asset." } }, "required": [ "instanceID" ], "description": "Find GameObject in opened Prefab or in the active Scene." }, "com.IvanMurzak.ReflectorNet.Model.SerializedMemberList": { "type": "array", "items": { "$ref": "#/$defs/com.IvanMurzak.ReflectorNet.Model.SerializedMember" } }, "com.IvanMurzak.ReflectorNet.Model.SerializedMember": { "type": "object", "properties": { "typeName": { "type": "string", "description": "Full type name. Eg: 'System.String', 'System.Int32', 'UnityEngine.Vector3', etc." }, "name": { "type": "string", "description": "Object name." }, "value": { "description": "Value of the object, serialized as a non stringified JSON element. Can be null if the value is not set. Can be default value if the value is an empty object or array json." }, "fields": { "type": "array", "items": { "$ref": "#/$defs/com.IvanMurzak.ReflectorNet.Model.SerializedMember", "description": "Nested field value." }, "description": "Fields of the object, serialized as a list of 'SerializedMember'." }, "props": { "type": "array", "items": { "$ref": "#/$defs/com.IvanMurzak.ReflectorNet.Model.SerializedMember", "description": "Nested property value." }, "description": "Properties of the object, serialized as a list of 'SerializedMember'." } }, "required": [ "typeName" ], "additionalProperties": false }, "AIGD.ComponentRef": { "type": "object", "properties": { "index": { "type": "integer", "description": "Component 'index' attached to a gameObject. The first index is '0' and that is usually Transform or RectTransform. Priority: 2. Default value is -1." }, "typeName": { "type": "string", "description": "Component type full name. Sample 'UnityEngine.Transform'. If the gameObject has two components of the same type, the output component is unpredictable. Priority: 3. Default value is null." }, "instanceID": { "$ref": "#/$defs/UnityEngine.EntityId", "description": "instanceID of the UnityEngine.Object. If this is '0', then it will be used as 'null'." } }, "required": [ "index", "instanceID" ], "description": "Component reference. Used to find a Component at GameObject." } }, "required": [ "gameObjectRef", "data" ] } ``` ## Output ### Output JSON Schema ```json { "type": "object", "properties": { "result": { "$ref": "#/$defs/com.IvanMurzak.Unity.MCP.Editor.API.Tool_Cinemachine-CinemachineModifyResponse" } }, "$defs": { "AIGD.GameObjectRef": { "type": "object", "properties": { "instanceID": { "$ref": "#/$defs/UnityEngine.EntityId", "description": "instanceID of the UnityEngine.Object. If it is '0' and 'path', 'name', 'assetPath' and 'assetGuid' is not provided, empty or null, then it will be used as 'null'. Priority: 1 (Recommended)" }, "path": { "type": "string", "description": "Path of a GameObject in the hierarchy Sample 'character/hand/finger/particle'. Priority: 2." }, "name": { "type": "string", "description": "Name of a GameObject in hierarchy. Priority: 3." }, "assetType": { "$ref": "#/$defs/System.Type", "description": "Type of the asset." }, "assetPath": { "type": "string", "description": "Path to the asset within the project. Starts with 'Assets/'" }, "assetGuid": { "type": "string", "description": "Unique identifier for the asset." } }, "required": [ "instanceID" ], "description": "Find GameObject in opened Prefab or in the active Scene." }, "UnityEngine.EntityId": { "type": "string", "pattern": "^[0-9]+$" }, "System.Type": { "type": "string" }, "AIGD.ComponentRef": { "type": "object", "properties": { "index": { "type": "integer", "description": "Component 'index' attached to a gameObject. The first index is '0' and that is usually Transform or RectTransform. Priority: 2. Default value is -1." }, "typeName": { "type": "string", "description": "Component type full name. Sample 'UnityEngine.Transform'. If the gameObject has two components of the same type, the output component is unpredictable. Priority: 3. Default value is null." }, "instanceID": { "$ref": "#/$defs/UnityEngine.EntityId", "description": "instanceID of the UnityEngine.Object. If this is '0', then it will be used as 'null'." } }, "required": [ "index", "instanceID" ], "description": "Component reference. Used to find a Component at GameObject." }, "System.String-1": { "type": "array", "items": { "type": "string" } }, "com.IvanMurzak.Unity.MCP.Editor.API.Tool_Cinemachine-CinemachineModifyResponse": { "type": "object", "properties": { "success": { "type": "boolean", "description": "Whether the modification was successful." }, "gameObjectRef": { "$ref": "#/$defs/AIGD.GameObjectRef", "description": "Reference to the GameObject containing the component." }, "componentRef": { "$ref": "#/$defs/AIGD.ComponentRef", "description": "Reference to the modified component." }, "componentIndex": { "type": "integer", "description": "Index of the component in the GameObject's component list." }, "componentType": { "type": "string", "description": "Full type name of the modified component." }, "logs": { "$ref": "#/$defs/System.String-1", "description": "Log of modifications and any warnings/errors." } }, "required": [ "success", "componentIndex" ] } }, "required": [ "result" ] } ```