unity_execute_code
Execute C# code in the Unity Editor to perform operations, queries, or automation with full access to Unity APIs.
Instructions
Execute arbitrary C# code inside the Unity Editor. The code runs in the editor context with access to all Unity APIs. Useful for one-off operations, queries, and automation. Return values are serialized to JSON.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | C# code to execute. Must be a valid method body. Access UnityEngine and UnityEditor namespaces. Use 'return' to send data back. | |
| port | No | Unity instance port (from unity_select_instance). Always include it when multiple instances run. |