Instant executable script with Roslyn - Update 0.11.0
#165
IvanMurzak
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🛠️ Immediate C# Script Execution in Unity with Roslyn
This tool lets you dynamically compile and execute C# code inside the Unity Editor—no need to create or save script files! It’s perfect for automation, rapid prototyping, and integrating with LLMs (Large Language Models) for AI-driven workflows.
How It Works
The
Tool_Script.Execute
method takes your C# code as a string, along with the class and static method name to invoke, and (optionally) serialized parameters.The tool checks that your code contains the specified class and method.
Uses Roslyn (
Microsoft.CodeAnalysis.CSharp
) to compile the code in-memory.Loads the compiled assembly, finds your static method, and invokes it on the Unity main thread.
Returns the result or any error as a string.
Example Usage
LLM sends this code to the tool, and it will create a new GameObject named
"LLM_Created"
in your scene—instantly!It also has access to Unity Editor API, which opens a lot of possibilities.
Why Use This?
Scripts are never saved to disk.
LLMs can generate and run Unity code on demand.
Test ideas or automate tasks without leaving the Editor.
Requirements & Limitations
Script
) and a static method (default:Main
).Unlock next-gen Unity workflows with instant, safe, and flexible C# code execution!
Beta Was this translation helpful? Give feedback.
All reactions