Roslyn Script Validation
By default, MCP for Unity uses a fast structural validator for scripts the LLM generates. For strict validation that catches undefined namespaces, types, and methods at write time — without a full Unity compile — install the optional Roslyn DLLs.
Most users don't need this. Enable it when:
- You're letting the LLM write a lot of unsupervised C# and want stricter feedback loops
- You're seeing recurring compile errors that survive the structural validator
- You're building custom tools that depend on accurate symbol resolution
One-click installer (recommended)
- Open Window → MCP for Unity.
- Scroll to the Runtime Code Execution (Roslyn) section in the Scripts / Validation tab.
- Click Install Roslyn DLLs.
The installer downloads the required NuGet packages, places the DLLs in Assets/Plugins/Roslyn/, and adds USE_ROSLYN to Scripting Define Symbols.
You can also trigger it from the menu: Window → MCP For Unity → Install Roslyn DLLs.
Manual install (if the installer isn't available)
- Install NuGetForUnity.
- Open Window → NuGet Package Manager.
- Install:
Microsoft.CodeAnalysisv5.0SQLitePCLRaw.corev3.0.2SQLitePCLRaw.bundle_e_sqlite3v3.0.2
- Add
USE_ROSLYNto Player Settings → Scripting Define Symbols. - Restart Unity.
Manual DLL install (no NuGetForUnity)
- Download
Microsoft.CodeAnalysis.CSharp.dlland its dependencies from NuGet.org. - Place DLLs in
Assets/Plugins/Roslyn/. - Ensure .NET compatibility settings are correct for your Unity version.
- Add
USE_ROSLYNto Scripting Define Symbols. - Restart Unity.
Verifying it's active
After restart, the MCP for Unity status panel shows Roslyn: enabled under the Scripts section. The validate_script tool now performs full semantic analysis rather than the structural pass.
Disabling
Remove USE_ROSLYN from Scripting Define Symbols. The plugin falls back to structural validation; the DLLs can stay in Assets/Plugins/Roslyn/ or be removed.