unity_execute_code
Run C# code inside the Unity Editor with full access to Unity and Editor APIs, returning a small JSON result so you can inspect changes, trigger actions, or query project state.
Instructions
Run C# in the Unity Editor with Unity API access. Return a small JSON result. If an error has executionCompleted=true, the code already ran; inspect its effects before retrying.
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. |