script-execute

Compile and execute C# code at runtime in Unity using Roslyn.

3.8k|349|Updated Apr 2, 2025
One-click install
npx skills add https://github.com/IvanMurzak/Unity-MCP --skill script-execute-ivanmurzak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: script-execute
Source: https://github.com/IvanMurzak/Unity-MCP/tree/main/Unity-MCP-Plugin/.claude/skills/script-execute
Command: npx skills add https://github.com/IvanMurzak/Unity-MCP --skill script-execute-ivanmurzak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Compile and execute C# code at runtime in Unity using Roslyn, enabling rapid experimentation and prototyping without rebuilding the project.

Core Features & Use Cases

  • Dynamic C# compilation and execution in Unity via Roslyn.
  • Supports two input modes: full code (default) and body-only mode (isMethodBody=true).
  • Pass Unity objects as method parameters using Ref wrappers (GameObjectRef, ComponentRef, etc.) or by direct type.

Quick Start

Provide your C# code to the tool and run it to execute in Unity, choosing full code or body-only mode.

Frequently Asked Questions about script-execute

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compile and run C# code at runtime in Unity?

You can dynamically compile and run C# code at runtime in Unity by providing your script to this Skill, which uses Roslyn to execute it without requiring a project rebuild.

Can I pass Unity objects as parameters to dynamically executed C# scripts?

Yes, you can pass Unity objects as parameters to runtime C# scripts by using Ref wrappers like GameObjectRef and ComponentRef, or by specifying direct types for primitive and Unity object references.

Does this runtime C# execution tool support body-only code snippets?

Yes, runtime C# execution supports body-only code snippets when you enable the isMethodBody mode, allowing you to run logic directly without defining a full class structure.

What is the best way to rapidly prototype C# scripts in Unity without rebuilding?

Dynamically compiling and executing C# via Roslyn at runtime is the best way to rapidly prototype in Unity, enabling immediate experimentation and testing without triggering project rebuilds.

Do I need Roslyn to dynamically execute C# code in Unity?

Yes, Roslyn is required for dynamic C# compilation and execution in Unity, as it provides the underlying compiler infrastructure needed to process and run your scripts at runtime.