Skip to content

[mcp-gap] Editor windows fail to load UXML under file:.../MCPForUnity submodule layout (basePath misses MCPForUnity/ segment) #16

@namdseasygoingvn

Description

@namdseasygoingvn

Summary

Under the file:com.coplaydev.unity-mcp/MCPForUnity submodule mount layout, AssetPathUtility.GetMcpPackageRootPath() returns a package root that is missing the MCPForUnity/ segment, so every Editor-window UXML load returns null. Both the main MCP window and the setup window become unusable, leaving the "Start Session" button unreachable.

Environment

  • Unity 6000.3.16f1, macOS
  • Reporter context: StickmanForge_IdleRPG consumer project, 2026-06-04
  • Package mounted via manifest: "com.coplaydev.unity-mcp": "file:com.coplaydev.unity-mcp/MCPForUnity"
  • Repo checked out at Packages/com.coplaydev.unity-mcp @ beta SHA 8a2b4267

Root cause

AssetPathUtility.GetMcpPackageRootPath() (MCPForUnity/Editor/Helpers/AssetPathUtility.cs:109) returns:

var packageInfo = PackageInfo.FindForAssembly(typeof(AssetPathUtility).Assembly);
if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.assetPath))
{
    return packageInfo.assetPath;   // => "Packages/com.coplaydev.unity-mcp"
}

PackageInfo.assetPath here is Packages/com.coplaydev.unity-mcp, but in this submodule layout the assets actually resolve under Packages/com.coplaydev.unity-mcp/MCPForUnity/.... So every:

AssetDatabase.LoadAssetAtPath($"{basePath}/Editor/Windows/*.uxml", ...)

returns null. Note the existing script-path fallback (lines 121-141, derives the root by stripping at /Editor/) would yield the correct .../MCPForUnity root — but it is only reached when packageInfo.assetPath is empty, which it is not in this layout.

Symptoms (console)

MCP-FOR-UNITY: Failed to load UXML at: Packages/com.coplaydev.unity-mcp/Editor/Windows/MCPForUnityEditorWindow.uxml
MCP-FOR-UNITY: Failed to load UXML at: Packages/com.coplaydev.unity-mcp/Editor/Windows/MCPSetupWindow.uxml

Both the main window and the setup window are unusable -> the "Start Session" button is unreachable.

Knock-on effect

UseHttpTransport defaults to true (EditorConfigurationCache.cs:131). With the window broken, the stdio bridge never auto-starts, so external MCP servers report "No Unity Editor instances found."

Workaround used

A project-local [InitializeOnLoadMethod] calling McpCiBoot.StartStdioForCi() to force the stdio transport.

Suggested fix

In GetMcpPackageRootPath(), validate the PackageInfo path by probing a known asset (e.g. the window UXML) and fall back to the script-path derivation (which already yields the correct .../MCPForUnity root). Alternatively, prefer PackageInfo.resolvedPath-relative asset paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions