Visitar URL original
[Feature]: CodeDom fallback — alias Object to UnityEngine.Object and hint to install Roslyn on compile failure · Issue #1439 · CoplayDev/unity-mcp · GitHub
Skip to content

[Feature]: CodeDom fallback — alias Object to UnityEngine.Object and hint to install Roslyn on compile failure #1439

Open

Description

@HivemindMinion

What problem are you trying to solve?

With compiler: "auto" and Roslyn not installed, execute_code silently uses CodeDom (C# 6). Two things then cost agents retries:

  1. Object is ambiguous in the generated wrapper (both System and UnityEngine are imported), so a very common Unity snippet fails:
    Line 6: `Object' is an ambiguous reference between `object' and `UnityEngine.Object'
    Line 6: `object' does not contain a definition for `FindObjectsByType'
    
    Every Object.FindObjectsByType<T>(...) / Object.Destroy(...) needs UnityEngine.Object. written out in full.
  2. Failures from syntax newer than C# 6 (tuple deconstruction, is not, switch expressions, etc.) come back as raw compiler errors, with no hint that the backend is the cause.

What would you like to see?

  • Add using Object = UnityEngine.Object; to the CodeDom wrapper (object keeps meaning System.Object). That matches what Unity scripts mean by Object in practice.
  • When a CodeDom compile fails, append a one-line hint: "Compiled with CodeDom (C# 6). Install Roslyn for C# 12 (see docs), or use C# 6 syntax."

Prior art / how do you work around this today?

Fully qualify UnityEngine.Object and write C# 6 by hand. The agent relearns this after the first failure in each session.

Scope hint

Very small: one alias line plus an error-message suffix.

Environment

  • Unity: 6000.3.8f1 (URP) · MCP for Unity: 10.2.1-beta.6 · Client: Claude Code · Transport: stdio · OS: Windows 11 Pro

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions