Kursach_StealthAction/.gemini/skills/terrain-modify-component/SKILL.md

308 lines
10 KiB
Markdown

---
name: terrain-modify-component
description: "Generic write: apply a `SerializedMember` diff to a terrain-related `Component` (`Terrain` or `TerrainCollider`) via ReflectorNet `TryModify`. Use 'terrain-get-component' first to inspect the structure. Route fields through the `fields` channel and properties through `props`."
metadata:
generated-by: mcp-plugin-dotnet
---
# Terrain / Modify Component (generic)
Modify a terrain component by applying a `SerializedMember` diff via ReflectorNet.
## Inputs
- `gameObjectRef` — the GameObject hosting the component (required).
- `data` — the `SerializedMember` diff to apply. Put C# *fields* in the `fields` channel and *properties* in the `props` channel (ReflectorNet resolves them separately — no cross-fallback).
- `componentRef` — optional. Resolves a specific component when the GameObject has more than one; otherwise the first `Terrain` (or `TerrainCollider`) is used.
## Behavior
Finds the target terrain 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 terrain-modify-component --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 terrain-modify-component --input-file args.json
> ```
>
> Or pipe via stdin (recommended):
> ```bash
> unity-mcp-cli run-tool terrain-modify-component --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 terrain component. |
| `data` | `any` | Yes | The SerializedMember diff to apply. Fields via the 'fields' channel, properties via 'props'. |
| `componentRef` | `any` | No | Optional reference to a specific 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_Terrain-TerrainModifyComponentResponse"
}
},
"$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_Terrain-TerrainModifyComponentResponse": {
"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"
]
}
```