script-execute
Compile and run C# code dynamically in Unity Editor using Roslyn. Execute temporary scripts with defined classes and static methods for immediate results.
Instructions
Compiles and executes C# code dynamically using Roslyn. The provided code must define a class with a static method to execute.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| csharpCode | Yes | C# code that compiles and executes immediately. It won't be stored as a script in the project. It is temporary one shot C# code execution using Roslyn. IMPORTANT: The code must define a class (e.g., 'public class Script') with a static method (e.g., 'public static object Main()'). Do NOT use top-level statements or code outside a class. Top-level statements are not supported and will cause compilation errors. | |
| className | No | The name of the class containing the method to execute. | Script |
| methodName | No | The name of the method to execute. It must be a static method in the class provided above. | Main |
| parameters | No | Serialized parameters to pass to the method. If the method does not require parameters, leave this empty. Schema: [{"name":"string","typeName":"string","value":any}] |