Keep local version of files
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
---
|
||||
name: unity-skill-create
|
||||
description: Create a new skill (MCP tool) for the Unity Editor by writing a C# (.cs) file that Unity compiles into the project. After compilation the new tool becomes callable through MCP. The file must be a partial class decorated with [AiToolType], each tool method must be decorated with [AiTool], the class name should match the file name, all Unity API calls must run via com.IvanMurzak.ReflectorNet.Utils.MainThread.Instance.Run(), and the method should either return a structured data model (for parseable output) or void (for side-effect-only operations). See the body of this skill for a full sample and best-practice notes.
|
||||
metadata:
|
||||
generated-by: mcp-plugin-dotnet
|
||||
---
|
||||
|
||||
# Skill (Tool) / Create
|
||||
|
||||
---
|
||||
name: unity-skill-create
|
||||
description: Create a new skill (MCP tool) for the Unity Editor by writing a C# (.cs) file that Unity compiles into the project. After compilation the new tool becomes callable through MCP. The file must be a partial class decorated with [AiToolType], each tool method must be decorated with [AiTool], the class name should match the file name, all Unity API calls must run via com.IvanMurzak.ReflectorNet.Utils.MainThread.Instance.Run(), and the method should either return a structured data model (for parseable output) or void (for side-effect-only operations). See the body of this skill for a full sample and best-practice notes.
|
||||
metadata:
|
||||
generated-by: mcp-plugin-dotnet
|
||||
---
|
||||
|
||||
# Skill (Tool) / Create
|
||||
|
||||
## Full sample
|
||||
|
||||
```csharp
|
||||
@@ -145,64 +145,64 @@ if (string.IsNullOrEmpty(name))
|
||||
```
|
||||
|
||||
### Always use MainThread for Unity API calls
|
||||
All Unity API calls (including `GameObject.Find`, `AssetDatabase`, `EditorUtility`, etc.) MUST run on the main thread. Wrap them in `MainThread.Instance.Run(() => { ... })` for synchronous operations, or `MainThread.Instance.RunAsync(async () => { ... })` when you need to await inside.
|
||||
|
||||
## How to Call
|
||||
|
||||
```bash
|
||||
unity-mcp-cli run-system-tool unity-skill-create --input '{
|
||||
"path": "string_value",
|
||||
"code": "string_value"
|
||||
}'
|
||||
```
|
||||
|
||||
> For complex input (multi-line strings, code), save the JSON to a file and use:
|
||||
> ```bash
|
||||
> unity-mcp-cli run-system-tool unity-skill-create --input-file args.json
|
||||
> ```
|
||||
>
|
||||
> Or pipe via stdin (recommended):
|
||||
> ```bash
|
||||
> unity-mcp-cli run-system-tool unity-skill-create --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 |
|
||||
|------|------|----------|-------------|
|
||||
All Unity API calls (including `GameObject.Find`, `AssetDatabase`, `EditorUtility`, etc.) MUST run on the main thread. Wrap them in `MainThread.Instance.Run(() => { ... })` for synchronous operations, or `MainThread.Instance.RunAsync(async () => { ... })` when you need to await inside.
|
||||
|
||||
## How to Call
|
||||
|
||||
```bash
|
||||
unity-mcp-cli run-system-tool unity-skill-create --input '{
|
||||
"path": "string_value",
|
||||
"code": "string_value"
|
||||
}'
|
||||
```
|
||||
|
||||
> For complex input (multi-line strings, code), save the JSON to a file and use:
|
||||
> ```bash
|
||||
> unity-mcp-cli run-system-tool unity-skill-create --input-file args.json
|
||||
> ```
|
||||
>
|
||||
> Or pipe via stdin (recommended):
|
||||
> ```bash
|
||||
> unity-mcp-cli run-system-tool unity-skill-create --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 |
|
||||
|------|------|----------|-------------|
|
||||
| `path` | `string` | Yes | Path for the C# (.cs) file to be created. Sample: "Assets/Skills/MySkill.cs".
|
||||
CRITICAL — Assembly Definition placement: If the project uses Assembly Definition files (.asmdef), you MUST place the script inside a folder that belongs to an assembly definition which already references all required dependencies (e.g. com.IvanMurzak.McpPlugin, UnityEditor, UnityEngine). Placing the file in the wrong assembly will cause compile errors due to missing type references. Before choosing a path, inspect existing .asmdef files with the assets-find tool to identify the correct assembly folder. |
|
||||
| `code` | `string` | Yes | C# code for the skill tool. |
|
||||
|
||||
### Input JSON Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"path",
|
||||
"code"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
This tool does not return structured output.
|
||||
|
||||
CRITICAL — Assembly Definition placement: If the project uses Assembly Definition files (.asmdef), you MUST place the script inside a folder that belongs to an assembly definition which already references all required dependencies (e.g. com.IvanMurzak.McpPlugin, UnityEditor, UnityEngine). Placing the file in the wrong assembly will cause compile errors due to missing type references. Before choosing a path, inspect existing .asmdef files with the assets-find tool to identify the correct assembly folder. |
|
||||
| `code` | `string` | Yes | C# code for the skill tool. |
|
||||
|
||||
### Input JSON Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"path",
|
||||
"code"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
This tool does not return structured output.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user