Detect and resolve Unity C# compilation errors using VSCode diagnostics. Use this skill when Unity projects have compilation errors that need diagnosis and automated fixes...
This skill enables automatic detection and resolution of Unity C# compilation errors by leveraging VSCode's diagnostic system. It collects real-time errors from the OmniSharp C# language server, analyzes error patterns against a curated database of common Unity issues, and proposes context-aware solutions for user approval before applying fixes.
Use this skill when:
Example user requests:
Follow this workflow when the skill is invoked:
Use the mcp__ide__getDiagnostics tool to collect errors from VSCode:
// Collect all project diagnostics
mcp__ide__getDiagnostics()
// Or target specific Unity script files
mcp__ide__getDiagnostics({ uri: "file:///path/to/PlayerController.cs" })
Filter the diagnostics to focus on Unity-relevant errors:
severity: "Error" (ignore warnings)source: "csharp" (OmniSharp C# diagnostics)For each detected error:
Extract error information:
uri and rangemessage (e.g., "CS0246")Match against error pattern database:
references/error-patterns.jsonRead affected file context:
For each error, create a structured fix proposal:
**Error**: CS0246 at PlayerController.cs:45
**Message**: The type or namespace name 'Rigidbody' could not be found
**Analysis**:
- Missing using directive for UnityEngine namespace
- Common Unity API usage pattern
**Proposed Solution**:
Add `using UnityEngine;` at the top of PlayerController.cs
**Changes Required**:
- File: Assets/Scripts/PlayerController.cs
- Action: Insert using directive at line 1
Before applying any fixes:
Present all proposed solutions in a clear, structured format
Use AskUserQuestion tool to get user approval:
Wait for explicit confirmation - do not apply fixes automatically
For each approved fix:
Example:
Edit({
file_path: "Assets/Scripts/PlayerController.cs",
old_string: "public class PlayerController : MonoBehaviour",
new_string: "using UnityEngine;\n\npublic class PlayerController : MonoBehaviour"
})
After applying fixes:
Check for .meta file conflicts:
Report VCS status:
After fixes are applied:
mcp__ide__getDiagnostics()The skill relies on references/error-patterns.json for error analysis. This database contains:
To analyze an error, load the database and match the error code:
Read({ file_path: "references/error-patterns.json" })
// Parse JSON and find errorCode entry
The skill includes Node.js scripts in scripts/ for complex error analysis:
Processes VSCode diagnostics JSON output and extracts Unity-relevant errors.
Usage:
node scripts/analyze-diagnostics.js <diagnostics-json-file>
Output:
This script can be run independently or invoked from the SKILL.md workflow when detailed analysis is needed.
When using this skill:
mcp__ide__getDiagnostics() without parameters to get complete error pictureNode.js script for processing VSCode diagnostics and filtering Unity-specific C# errors.
Curated database of common Unity C# compilation errors with solutions and Unity-specific guidance.