Summary
Installing com.coplaydev.unity-mcp from the moving #beta branch currently resolves to commit 37ef0160663d7cee0fe60e1321075e51f9a19e52 / package version 9.6.9-beta.5.
In Unity 2022.3.4f1, that package fails to compile before the MCP server can be used. This looks like a regression introduced by PR #1097 and then published as 9.6.9-beta.5 by PR #1099.
Environment
- Unity:
2022.3.4f1
- OS: Windows
- Package source:
"com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta"
- Resolved package:
- commit:
37ef0160663d7cee0fe60e1321075e51f9a19e52
- package version:
9.6.9-beta.5
Actual result
Unity enters Safe Mode / compile fails with these errors:
Library\PackageCache\com.coplaydev.unity-mcp@37ef016066\Runtime\Helpers\UnityFindObjectsCompat.cs(66,20): error CS0103: The name 'LegacyFindObjectsOfType' does not exist in the current context
Library\PackageCache\com.coplaydev.unity-mcp@37ef016066\Runtime\Helpers\ScreenshotUtility.cs(255,28): error CS0103: The name 'CaptureFromCameraToAssetsFolder' does not exist in the current context
Library\PackageCache\com.coplaydev.unity-mcp@37ef016066\Runtime\Helpers\ScreenshotUtility.cs(260,46): error CS7036: There is no argument given that corresponds to the required formal parameter 'folderOverride' of 'ScreenshotUtility.PrepareCaptureResult(string, int, bool, string, bool)'
Library\PackageCache\com.coplaydev.unity-mcp@37ef016066\Runtime\Helpers\ScreenshotUtility.cs(273,32): error CS0103: The name 'CaptureFromCameraToAssetsFolder' does not exist in the current context
Library\PackageCache\com.coplaydev.unity-mcp@37ef016066\Runtime\Helpers\ScreenshotUtility.cs(311,45): error CS1061: 'ScreenshotCaptureResult' does not contain a definition for 'AssetsRelativePath' and no accessible extension method 'AssetsRelativePath' accepting a first argument of type 'ScreenshotCaptureResult' could be found
Expected result
The Unity package should compile cleanly on Unity 2022.3.x, or the package metadata should exclude unsupported Unity versions.
Suspected cause
There appear to be two separate regressions.
1. UnityFindObjectsCompat.cs preprocessor mismatch
For Unity 2022.3.x, FindAll(Type type, bool includeInactive) falls into the legacy fallback branch because the new include-inactive overload is gated behind UNITY_2023_1_OR_NEWER.
However, the legacy reflection helpers are compiled only when !UNITY_2022_3_OR_NEWER, so Unity 2022.3.x calls LegacyFindObjectsOfType(...) while that helper is excluded by preprocessor defines.
Unity 2022.3 documents the overload:
Object.FindObjectsByType(Type type, FindObjectsInactive findObjectsInactive, FindObjectsSortMode sortMode)
So the guard probably needs to include Unity 2022.3.x, or the legacy helper must remain compiled for the fallback branch.
Possible fix:
-#elif UNITY_2023_1_OR_NEWER
+#elif UNITY_2022_3_OR_NEWER
return UObject.FindObjectsByType(type,
includeInactive ? UnityEngine.FindObjectsInactive.Include : UnityEngine.FindObjectsInactive.Exclude,
UnityEngine.FindObjectsSortMode.None);
2. ScreenshotUtility.cs incomplete rename/refactor
The beta code seems to have renamed:
AssetsRelativePath -> ProjectRelativePath
CaptureFromCameraToAssetsFolder -> CaptureFromCameraToProjectFolder
CaptureToAssetsFolder -> CaptureToProjectFolder
PrepareCaptureResult(...) now requires folderOverride
But CaptureComposited(...) still references old names/signatures:
CaptureFromCameraToAssetsFolder(...)
PrepareCaptureResult(fileName, superSize, ensureUniqueFileName, isAsync: false)
result.AssetsRelativePath
The same stale Assets* API names also appear in Editor/Tools/ManageScene.cs, although the Runtime assembly fails first, so Unity reports the Runtime errors before possible Editor assembly errors.
Possible fixes:
- Update remaining old call sites to the new
Project* names and pass folderOverride: null where needed.
- Or keep backward-compatible wrapper members temporarily:
public string AssetsRelativePath => ProjectRelativePath;
public static ScreenshotCaptureResult CaptureFromCameraToAssetsFolder(
Camera camera,
string fileName = null,
int superSize = 1,
bool ensureUniqueFileName = true,
bool includeImage = false,
int maxResolution = 0)
{
return CaptureFromCameraToProjectFolder(
camera, fileName, superSize, ensureUniqueFileName, includeImage, maxResolution);
}
Workaround
Pinning the Unity package to a fixed stable release avoids the broken beta commit:
"com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v9.6.8"
This is only a workaround; it avoids 37ef016... / 9.6.9-beta.5 rather than fixing the beta branch.
Related PRs / commits
Summary
Installing
com.coplaydev.unity-mcpfrom the moving#betabranch currently resolves to commit37ef0160663d7cee0fe60e1321075e51f9a19e52/ package version9.6.9-beta.5.In Unity
2022.3.4f1, that package fails to compile before the MCP server can be used. This looks like a regression introduced by PR #1097 and then published as9.6.9-beta.5by PR #1099.Environment
2022.3.4f137ef0160663d7cee0fe60e1321075e51f9a19e529.6.9-beta.5Actual result
Unity enters Safe Mode / compile fails with these errors:
Expected result
The Unity package should compile cleanly on Unity
2022.3.x, or the package metadata should exclude unsupported Unity versions.Suspected cause
There appear to be two separate regressions.
1.
UnityFindObjectsCompat.cspreprocessor mismatchFor Unity
2022.3.x,FindAll(Type type, bool includeInactive)falls into the legacy fallback branch because the new include-inactive overload is gated behindUNITY_2023_1_OR_NEWER.However, the legacy reflection helpers are compiled only when
!UNITY_2022_3_OR_NEWER, so Unity2022.3.xcallsLegacyFindObjectsOfType(...)while that helper is excluded by preprocessor defines.Unity
2022.3documents the overload:So the guard probably needs to include Unity
2022.3.x, or the legacy helper must remain compiled for the fallback branch.Possible fix:
2.
ScreenshotUtility.csincomplete rename/refactorThe beta code seems to have renamed:
AssetsRelativePath->ProjectRelativePathCaptureFromCameraToAssetsFolder->CaptureFromCameraToProjectFolderCaptureToAssetsFolder->CaptureToProjectFolderPrepareCaptureResult(...)now requiresfolderOverrideBut
CaptureComposited(...)still references old names/signatures:CaptureFromCameraToAssetsFolder(...)PrepareCaptureResult(fileName, superSize, ensureUniqueFileName, isAsync: false)result.AssetsRelativePathThe same stale
Assets*API names also appear inEditor/Tools/ManageScene.cs, although the Runtime assembly fails first, so Unity reports the Runtime errors before possible Editor assembly errors.Possible fixes:
Project*names and passfolderOverride: nullwhere needed.Workaround
Pinning the Unity package to a fixed stable release avoids the broken beta commit:
This is only a workaround; it avoids
37ef016.../9.6.9-beta.5rather than fixing the beta branch.Related PRs / commits