Skip to content

feat: Unity 2020.3 LTS support (C#8 + netstandard2.0 + 2021.2 API guards) - #1323

Open
RoyougiShiki wants to merge 10 commits into
CoplayDev:betafrom
RoyougiShiki:pr/compat-2020
Open

feat: Unity 2020.3 LTS support (C#8 + netstandard2.0 + 2021.2 API guards)#1323
RoyougiShiki wants to merge 10 commits into
CoplayDev:betafrom
RoyougiShiki:pr/compat-2020

Conversation

@RoyougiShiki

@RoyougiShiki RoyougiShiki commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Enable Unity 2020.3 LTS support for MCP for Unity. The package currently requires 2021.3+; this PR lowers the floor to 2020.3 by removing C# 9 syntax and shimming .NET Core 2.1+ / Unity 2021.2+ APIs that 2020.3 lacks.

All changes are behavior-neutral on 2021.3+: newer Unity versions take the same code paths as before (guarded with #if UNITY_2021_2_OR_NEWER), and the 2020.3 branches are functionally equivalent implementations, not stubs.

Verified on Unity 2020.3.24f1: full package compile with 0 errors / 0 warnings, all 11 UXML files load, editor windows open, dropdown control + tool routing runtime checks pass. A dedicated test project is included (TestProjects/Unity2020Compat).

What changed

1. C# 9 → C# 8 (2020.3 ships the C# 8 compiler)

  • Target-typed new() / new(...) → explicit types (~65 sites)
  • is not T x pattern → !(x is T x) (20 sites)
  • is A or B / property-pattern or combos → equivalent boolean expressions
  • Switch-expression or arms → split arms; target-typed ternaries → explicit IMcpResponse casts

2. .NET API shims (netstandard2.0 vs 2.1)

  • string.Contains(char), Contains(str, StringComparison), string.Join(char, …) → netstandard2.0 equivalents
  • Index/Range slicing (s[..^n]) → Substring
  • Math.ClampMathf.Clamp, Task.IsCompletedSuccessfullyTaskStatus.RanToCompletion
  • Dictionary.Remove(k, out v)TryGetValue + Remove
  • ProcessStartInfo.ArgumentList → new AddArg() extension (argument-quoting equivalent)
  • Path.GetRelativePath, Enum.TryParse(Type,…) 4-arg, Rfc2898DeriveBytes 4-arg → 2020.3-compatible equivalents

3. Unity 2021.2+ APIs behind version guards (2020.3 branches are equivalents, not stubs)

  • NamedBuildTargetBuildTargetGroup (2020.3 has all the same PlayerSettings overloads)
  • PrefabStage/PrefabStageUtilityUnityEditor.Experimental.SceneManagement (moved in 2021.2), OpenPrefabAssetDatabase.OpenAsset + GetCurrentPrefabStage
  • PackageInfo.GetAllRegisteredPackages() → new RegisteredPackageInfo helper: 2021.2+ wraps the native API; 2020.3 parses authoritative Packages/packages-lock.json (synchronous file IO — the alternative Client.List polling deadlocks the editor, see commit 3c690f0)
  • Client.AddAndRemove → per-package Add/Remove; StandaloneBuildSubtarget/CleanBuildCache guarded

4. UI Toolkit

  • DropdownField (2021.2+) → new CompatDropdownField: 2021.2+ inherits DropdownField unchanged; 2020.3 self-draws an equivalent popup (PopupField<string> keeps choices private) with UxmlFactory/UxmlTraits. 4 UXML files updated.

5. Documented 2020.3-only gaps (no equivalent API exists anywhere in 2020.3)

  • UIDocument runtime UI tools return an explicit "requires Unity 2021.2+" error (tools stay registered)
  • LightingSettings.lightmapCompression, BuildOptions.CleanBuildCache, standalone Server subtarget, ProfilerCategory.FileIO/VirtualTexturing → guarded/skipped on 2020.3

Notes for maintainers

  • Full patch inventory & sync strategy: docs/UNITY_2020_3_COMPAT.md
  • Test project: TestProjects/Unity2020Compat (2020.3.24f1, file: link to ../../MCPForUnity, one-click verify_compile.cmd)
  • If you'd rather not commit to a 2020.3 floor, the C# 8 + .NET shim changes (sections 1–2) are independently valuable and mergeable on their own.

Summary by CodeRabbit

  • New Features

    • Added support for Unity 2020.3, including compatible package management, build settings, prefab stages, graphics, secure process arguments, and UI Toolkit controls.
    • Added cross-version dropdown controls for editor settings and configuration panels.
  • Bug Fixes

    • Improved package detection and metadata handling across supported Unity versions.
    • Added graceful fallbacks for features unavailable in older Unity releases.
  • Documentation

    • Added Unity 2020.3 compatibility guidance and a validation project.

- C#9 -> C#8: target-typed new(), is not, or-patterns, switch-arms (95+ sites)
- .NET 2.0 API shims: Contains/Join/Range/Math.Clamp/ArgumentList etc (37 sites)
- 2021.2+ Unity APIs behind #if UNITY_2021_2_OR_NEWER with equivalent 2020.3 impls:
  NamedBuildTarget, PrefabStageUtility (Experimental ns), subtarget, GetAllRegisteredPackages,
  AddAndRemoveRequest, ShaderPropertyType.Int, ProfilerCategory
- New CompatDropdownField (DropdownField not in 2020.3): 2021.2+ native,
  2020.3 self-drawn equivalent with UxmlFactory; 4 UXMLs migrated
- Verified: Unity 2020.3.24f1 batchmode compile 0 error/0 warning,
  all 11 UXMLs load, window/dropdown/tool-routing runtime checks pass
- docs/UNITY_2020_3_COMPAT.md: full patch inventory for sync strategy
- TestProjects/Unity2020Compat (2020.3.24f1, file: link to ../../MCPForUnity)
- verify_compile.cmd one-click batchmode check (0 error / 0 warning verified)
- Library/Logs/Temp gitignored
…son parsing on 2020.3

GetRegisteredPackages() 2020.3 branch used Client.List(true) + Thread.Sleep,
which deadlocks the editor (PackageManager requests need main-thread pumping).
New RegisteredPackageInfo helper: 2021.2+ wraps PackageInfo.GetAllRegisteredPackages(),
2020.3 parses authoritative Packages/packages-lock.json (synchronous file IO) plus
best-effort package.json metadata (description/author/resolvedPath).
Verified at runtime on 2020.3.24f1: 46 packages resolved, deps/metadata correct.
Rebase baseline for PR: upstream beta adds CodeDom DLL-output refactor in
ExecuteCode.cs and stdio bridge timeout config; both verified compiling
on Unity 2020.3.24f1 (0 errors, 0 warnings).
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bfd8a97e-9e31-426a-b469-fbca8f577dcf

📥 Commits

Reviewing files that changed from the base of the PR and between 775f15b and 639279b.

⛔ Files ignored due to path filters (1)
  • TestProjects/Unity2020Compat/compile_check.log is excluded by !**/*.log
📒 Files selected for processing (1)
  • TestProjects/Unity2020Compat/verify_compile.cmd
🚧 Files skipped from review as they are similar to previous changes (1)
  • TestProjects/Unity2020Compat/verify_compile.cmd

📝 Walkthrough

Walkthrough

The package now targets Unity 2020.3. The changes add older C# and .NET-compatible syntax, Unity API fallbacks, package metadata compatibility, process argument handling, a cross-version dropdown control, and a Unity 2020.3 compile-validation project.

Changes

Unity 2020.3 compatibility

Layer / File(s) Summary
Compatibility implementation and validation
MCPForUnity/..., TestProjects/Unity2020Compat/..., docs/UNITY_2020_3_COMPAT.md
Modern syntax and APIs now use Unity 2020.3-compatible alternatives. Unity-version guards cover editor APIs, package operations, secure storage, transport, graphics, profiler, and UI behavior.
Cross-version dropdown and package integration
MCPForUnity/Editor/Windows/..., MCPForUnity/Editor/Services/...
CompatDropdownField provides native behavior on newer Unity versions and an IMGUI implementation on Unity 2020.3. Package enumeration and installation use version-specific implementations.
Compatibility validation assets
MCPForUnity/package.json, TestProjects/Unity2020Compat/..., docs/UNITY_2020_3_COMPAT.md
The minimum Unity version is 2020.3. The compatibility project, compile script, lockfile, README, and compatibility record were added.

Estimated code review effort: 5 (Critical) | ~120 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding Unity 2020.3 support through compatibility updates.
Description check ✅ Passed The description thoroughly covers the compatibility changes, testing results, documentation, test project, and known gaps, but omits some template headings and issue links.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
MCPForUnity/Editor/Tools/ManagePackages.cs (1)

363-384: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Handle packages without author metadata.

RegisteredPackageInfo.GetRegisteredPackages() can return author == null; its Unity package path maps a missing PackageInfo.author to default (MCPForUnity/Editor/Services/RegisteredPackageInfo.cs:43-144). The access at Line 384 then throws, and get_package_info returns an error for that package. Use a null-safe author value.

The nullable behavior comes from MCPForUnity/Editor/Services/RegisteredPackageInfo.cs.

Proposed fix
-                        author = info.author.name,
+                        author = info.author != null ? info.author.name : null,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Tools/ManagePackages.cs` around lines 363 - 384, Update
the get_package_info response construction around
RegisteredPackageInfo.GetRegisteredPackages() to access info.author.name
null-safely, returning an appropriate empty or default author value when author
metadata is missing while preserving the existing author name for packages that
provide it.
MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs (1)

515-529: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not report an unsupported setting as changed.

On Unity versions before 2021.2, this branch returns true without modifying LightingSettings. SetSettings then adds the property to changed and returns success.

Return false, or return an explicit unsupported-setting error, so callers do not treat the request as applied.

Proposed fix
 `#else`
-                    return true;
+                    return false;
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs` around lines 515 - 529,
Update the pre-2021.2 branch of the lightmap compression handling in SetSettings
to return false instead of reporting success, since it does not modify
LightingSettings. Preserve the existing parsing and assignment behavior for
Unity 2021.2 and newer so unsupported requests are not added to changed or
treated as applied.
MCPForUnity/Editor/Tools/Graphics/SkyboxOps.cs (1)

14-27: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Declare CustomReflectionTexture as Texture.

RenderSettings.customReflectionTexture is Texture, while legacy RenderSettings.customReflection is Cubemap. The current getter does not compile on Unity 2022.1 and newer. Use Texture for the helper and cast value as Cubemap in the legacy setter. Route the version-gated API access through a Unity*Compat.cs shim.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Tools/Graphics/SkyboxOps.cs` around lines 14 - 27, Change
CustomReflectionTexture from Cubemap to Texture so the Unity 2022.1+ getter
matches RenderSettings.customReflectionTexture. Move the version-gated
RenderSettings access into the project’s Unity*Compat.cs shim, and in the legacy
setter cast value as Cubemap before assigning RenderSettings.customReflection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/UNITY_2020_3_COMPAT.md`:
- Around line 54-56: Update the PackageInfo.GetAllRegisteredPackages entry in
the UNITY_2020_3_COMPAT table to document synchronous reading of
Packages/packages-lock.json for resolved packages, replacing the incorrect
Client.List(true) polling description.
- Around line 76-80: Update the Unity 2020.3 compatibility handling for
LightingSettings.lightmapCompression writes, BuildOptions.CleanBuildCache via
clean_build, and Standalone Server subtarget requests so each unsupported
operation reports an explicit warning or error to callers instead of silently
succeeding, being ignored, or falling back to Player(0). Preserve the documented
tool behavior while exposing the compatibility limitation.

In `@MCPForUnity/Editor/Helpers/ProcessArgumentListCompat.cs`:
- Around line 13-21: Update the quoting helper used by ProcessStartInfo.AddArg
to implement standard Windows command-line argument quoting, preserving
backslashes unless they precede a quote or the closing delimiter. Ensure
arguments containing spaces, embedded quotes, and trailing backslashes
round-trip unchanged through the child-process parser, and add tests covering
each case.

In `@MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs`:
- Line 96: Update the key derivation in SecureKeyStore.TryGet to preserve
PBKDF2-SHA256 compatibility with existing files: replace the three-argument
Rfc2898DeriveBytes usage with a Unity-compatible SHA-256 implementation, or
explicitly retain the legacy SHA-256 derivation when reading and migrating files
before rewriting them.

In `@MCPForUnity/Editor/Tools/Build/BuildRunner.cs`:
- Around line 72-74: Move the version-dependent handling of options.subtarget
and clean_build out of BuildRunner and into the appropriate Unity*Compat.cs
compatibility shim. Preserve Unity 2020.3 behavior by ignoring clean_build and
using Player(0) for subtarget, while retaining the newer Unity behavior through
the shim; remove the direct version guards from the BuildRunner flow.

In `@MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs`:
- Around line 67-71: Update the architecture mapping in the build-settings
helper to stop treating x86_64 as a valid value for the generic
PlayerSettings.GetArchitecture/SetArchitecture API, since value 0 represents
None. Remove or reject x86_64 in the write mapping, align the read mapping with
the documented architecture values, and update validation messaging accordingly;
use a target-specific API such as PlayerSettings.Android.targetArchitectures if
x86_64 support is required.

In `@MCPForUnity/Editor/Tools/Build/BuildTargetMapping.cs`:
- Around line 157-167: Update ResolveSubtarget and the BuildRunner/ManageBuild
scheduling flow so a "server" subtarget on Unity 2020.3 is rejected before the
job is scheduled, rather than silently returning 0 and leaving
BuildPlayerOptions.subtarget unset. Use a version-check shim in the MCPForUnity
runtime Unity*Compat.cs helpers, while preserving server support on Unity 2021.2
and newer.

In `@MCPForUnity/Editor/Tools/ManageBuild.cs`:
- Around line 218-222: Centralize the UNITY_2021_2_OR_NEWER standalone subtarget
compatibility logic in a Unity*Compat helper under Runtime/Helpers, exposing
read, write, and player-fallback behavior. Update the current-platform read,
platform switch, and batch-build callback in ManageBuild.cs to use that helper,
removing their direct preprocessor branches while preserving existing behavior.
- Around line 247-253: Update the subtarget handling in the build-management
method around subtargetStr so a server request on Unity versions before 2021.2
does not silently succeed with the player subtarget. Add an explicit unsupported
error for server in the older-version preprocessor branch, or ensure the
response reports player as the effective subtarget; preserve the existing
server/player assignments on Unity 2021.2 and newer.

In `@MCPForUnity/Editor/Windows/Components/CompatDropdownField.cs`:
- Around line 110-139: Update SetValueWithoutNotify and UpdateValueFromIndex to
accept and propagate a notification flag, passing false from
SetValueWithoutNotify so it updates the selected value without dispatching
callbacks. Preserve callback dispatch for normal notifying updates, matching the
Unity 2021.3 silent behavior.

In `@MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs`:
- Around line 1061-1066: Serialize the legacy Unity Package Manager additions
instead of starting every request in the foreach loop. Update the bulk-add flow
around PollUpmAddRequest at
MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs lines 1061-1066 and
1077-1082 to queue package IDs, start the next request only after the current
request completes successfully, and preserve completion callback behavior.

In `@TestProjects/Unity2020Compat/Packages/manifest.json`:
- Line 8: Align the Unity Test Framework dependency to one compatible version,
preferably the existing 1.1.31 required by MCPForUnity/package.json: update
TestProjects/Unity2020Compat/Packages/manifest.json and both affected
resolutions in TestProjects/Unity2020Compat/Packages/packages-lock.json (lines
15-16 and 93-102), regenerate the lock file with Unity 2020.3, then run
tools/check-unity-versions.sh.

In `@TestProjects/Unity2020Compat/README.md`:
- Around line 11-14: Update the Unity command block in the README to be runnable
interactively from cmd.exe by replacing the batch-only %~dp0 project path with
%CD% after the cd /d command, or explicitly direct users to run
verify_compile.cmd.

In `@TestProjects/Unity2020Compat/verify_compile.cmd`:
- Around line 2-3: Update verify_compile.cmd to remove hardcoded project and
Unity installation paths. Derive the project directory from %~dp0, and resolve
the Unity executable from a supplied argument or environment variable while
preserving the existing batch verification arguments.
- Around line 3-4: Update the Unity invocation and verification flow in
verify_compile.cmd to use one consistent log filename, capture Unity’s exit
status before inspecting the log, and fail when the log contains “error CS” or
does not contain “Exiting batchmode successfully now!”. Return the computed
result using exit /b, without treating compiler warnings as failures.

---

Outside diff comments:
In `@MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs`:
- Around line 515-529: Update the pre-2021.2 branch of the lightmap compression
handling in SetSettings to return false instead of reporting success, since it
does not modify LightingSettings. Preserve the existing parsing and assignment
behavior for Unity 2021.2 and newer so unsupported requests are not added to
changed or treated as applied.

In `@MCPForUnity/Editor/Tools/Graphics/SkyboxOps.cs`:
- Around line 14-27: Change CustomReflectionTexture from Cubemap to Texture so
the Unity 2022.1+ getter matches RenderSettings.customReflectionTexture. Move
the version-gated RenderSettings access into the project’s Unity*Compat.cs shim,
and in the legacy setter cast value as Cubemap before assigning
RenderSettings.customReflection.

In `@MCPForUnity/Editor/Tools/ManagePackages.cs`:
- Around line 363-384: Update the get_package_info response construction around
RegisteredPackageInfo.GetRegisteredPackages() to access info.author.name
null-safely, returning an appropriate empty or default author value when author
metadata is missing while preserving the existing author name for packages that
provide it.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 268cad2d-56b5-4346-a515-383396434c05

📥 Commits

Reviewing files that changed from the base of the PR and between c21bf49 and 000fde5.

⛔ Files ignored due to path filters (1)
  • TestProjects/Unity2020Compat/compile_check.log is excluded by !**/*.log
📒 Files selected for processing (95)
  • MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
  • MCPForUnity/Editor/Dependencies/PlatformDetectors/LinuxPlatformDetector.cs
  • MCPForUnity/Editor/Dependencies/PlatformDetectors/MacOSPlatformDetector.cs
  • MCPForUnity/Editor/Dependencies/PlatformDetectors/WindowsPlatformDetector.cs
  • MCPForUnity/Editor/External/Tommy.cs
  • MCPForUnity/Editor/Helpers/AssetPathUtility.cs
  • MCPForUnity/Editor/Helpers/CodexConfigHelper.cs
  • MCPForUnity/Editor/Helpers/GameObjectLookup.cs
  • MCPForUnity/Editor/Helpers/HttpEndpointUtility.cs
  • MCPForUnity/Editor/Helpers/McpConfigurationHelper.cs
  • MCPForUnity/Editor/Helpers/McpLogRecord.cs
  • MCPForUnity/Editor/Helpers/PortManager.cs
  • MCPForUnity/Editor/Helpers/ProcessArgumentListCompat.cs
  • MCPForUnity/Editor/Helpers/ProcessArgumentListCompat.cs.meta
  • MCPForUnity/Editor/Helpers/ProjectIdentityUtility.cs
  • MCPForUnity/Editor/Helpers/UnityTypeResolver.cs
  • MCPForUnity/Editor/Helpers/VectorParsing.cs
  • MCPForUnity/Editor/Models/McpClient.cs
  • MCPForUnity/Editor/Resources/Editor/GetPrefabStage.cs
  • MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs
  • MCPForUnity/Editor/Security/SecureKeyStore/LinuxSecretToolKeyStore.cs
  • MCPForUnity/Editor/Security/SecureKeyStore/MacKeychainKeyStore.cs
  • MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs
  • MCPForUnity/Editor/Services/AssetGen/Import/ModelImportPipeline.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/LocalImage.cs
  • MCPForUnity/Editor/Services/EditorStateCache.cs
  • MCPForUnity/Editor/Services/IClientConfigurationService.cs
  • MCPForUnity/Editor/Services/PackageJobManager.cs
  • MCPForUnity/Editor/Services/PackageUpdateService.cs
  • MCPForUnity/Editor/Services/PathResolverService.cs
  • MCPForUnity/Editor/Services/RegisteredPackageInfo.cs
  • MCPForUnity/Editor/Services/RegisteredPackageInfo.cs.meta
  • MCPForUnity/Editor/Services/TestJobManager.cs
  • MCPForUnity/Editor/Services/TestRunStatus.cs
  • MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs
  • MCPForUnity/Editor/Services/Transport/Transports/StdioBridgeHost.cs
  • MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs
  • MCPForUnity/Editor/Setup/McpForUnitySkillInstaller.cs
  • MCPForUnity/Editor/Setup/SkillSyncService.cs
  • MCPForUnity/Editor/Tools/Animation/ClipCreate.cs
  • MCPForUnity/Editor/Tools/Animation/ControllerCreate.cs
  • MCPForUnity/Editor/Tools/AssetGen/AssetGenToolHelpers.cs
  • MCPForUnity/Editor/Tools/AssetGen/ImportModel.cs
  • MCPForUnity/Editor/Tools/BatchExecute.cs
  • MCPForUnity/Editor/Tools/Build/BuildJob.cs
  • MCPForUnity/Editor/Tools/Build/BuildRunner.cs
  • MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs
  • MCPForUnity/Editor/Tools/Build/BuildTargetMapping.cs
  • MCPForUnity/Editor/Tools/Cameras/CameraCreate.cs
  • MCPForUnity/Editor/Tools/Cameras/CameraHelpers.cs
  • MCPForUnity/Editor/Tools/CommandRegistry.cs
  • MCPForUnity/Editor/Tools/ExecuteCode.cs
  • MCPForUnity/Editor/Tools/GameObjects/ComponentResolver.cs
  • MCPForUnity/Editor/Tools/GameObjects/GameObjectComponentHelpers.cs
  • MCPForUnity/Editor/Tools/GameObjects/GameObjectModify.cs
  • MCPForUnity/Editor/Tools/GameObjects/ManageGameObjectCommon.cs
  • MCPForUnity/Editor/Tools/Graphics/GraphicsHelpers.cs
  • MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs
  • MCPForUnity/Editor/Tools/Graphics/RenderPipelineOps.cs
  • MCPForUnity/Editor/Tools/Graphics/SkyboxOps.cs
  • MCPForUnity/Editor/Tools/Graphics/VolumeOps.cs
  • MCPForUnity/Editor/Tools/ManageBuild.cs
  • MCPForUnity/Editor/Tools/ManageComponents.cs
  • MCPForUnity/Editor/Tools/ManagePackages.cs
  • MCPForUnity/Editor/Tools/ManageScene.cs
  • MCPForUnity/Editor/Tools/ManageScript.cs
  • MCPForUnity/Editor/Tools/ManageScriptableObject.cs
  • MCPForUnity/Editor/Tools/ManageUI.cs
  • MCPForUnity/Editor/Tools/Prefabs/ManagePrefabs.cs
  • MCPForUnity/Editor/Tools/Profiler/Operations/CounterOps.cs
  • MCPForUnity/Editor/Tools/ReadConsole.cs
  • MCPForUnity/Editor/Tools/UnityReflect.cs
  • MCPForUnity/Editor/Tools/Vfx/ParticleControl.cs
  • MCPForUnity/Editor/Windows/Components/AssetGen/McpAssetGenSection.cs
  • MCPForUnity/Editor/Windows/Components/AssetGen/McpAssetGenSection.uxml
  • MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.cs
  • MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.uxml
  • MCPForUnity/Editor/Windows/Components/CompatDropdownField.cs
  • MCPForUnity/Editor/Windows/Components/CompatDropdownField.cs.meta
  • MCPForUnity/Editor/Windows/Components/Resources/McpResourcesSection.cs
  • MCPForUnity/Editor/Windows/Components/Tools/McpToolsSection.cs
  • MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefItem.uxml
  • MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs
  • MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.uxml
  • MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs
  • MCPForUnity/Editor/Windows/MCPSetupWindow.cs
  • MCPForUnity/Runtime/Serialization/UnityTypeConverters.cs
  • MCPForUnity/package.json
  • TestProjects/Unity2020Compat/.gitignore
  • TestProjects/Unity2020Compat/Packages/manifest.json
  • TestProjects/Unity2020Compat/Packages/packages-lock.json
  • TestProjects/Unity2020Compat/ProjectSettings/ProjectVersion.txt
  • TestProjects/Unity2020Compat/README.md
  • TestProjects/Unity2020Compat/verify_compile.cmd
  • docs/UNITY_2020_3_COMPAT.md

Comment thread docs/UNITY_2020_3_COMPAT.md
Comment on lines +76 to +80
| `UIDocument` runtime UI 组件(attach_ui_document / detach_ui_document / get_visual_tree / render_ui / modify_visual_element / create_panel_settings / update_panel_settings) | 2021.2+ 才有 | 返回明确错误信息 "requires Unity 2021.2 or newer",工具列表仍注册 |
| `LightingSettings.lightmapCompression` | 2021.2+ 才有 | 读取省略该字段,写入静默跳过 |
| `BuildOptions.CleanBuildCache` | 2021.2+ 才有 | clean_build 参数被忽略 |
| Standalone Server 子目标构建 | 2021.2+ 才有 | subtarget 固定为 Player(0) |
| `ProfilerCategory.FileIO` / `VirtualTexturing` | 2021.2+ 才有 | 映射到相近分类 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 5 'lightmapCompression|clean_build|Standalone|subtarget|unsupported|warning|error' \
  MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs \
  MCPForUnity/Editor/Tools/Build/BuildRunner.cs \
  MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs

Repository: CoplayDev/unity-mcp

Length of output: 7062


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- documentation ---'
sed -n '60,90p' docs/UNITY_2020_3_COMPAT.md

printf '%s\n' '--- LightBakingOps handlers and callers ---'
rg -n -C 8 'Get|Set|lightmapCompression|SetLight|HandleCommand|return false|return true' \
  MCPForUnity/Editor/Tools/Graphics/LightBakingOps.cs

printf '%s\n' '--- BuildRunner callers and result handling ---'
rg -n -C 10 'CreateBuildOptions|clean_build|subtarget|BuildPipeline.BuildPlayer|BuildReport|BuildSummary|return' \
  MCPForUnity/Editor/Tools/Build/BuildRunner.cs \
  MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs \
  MCPForUnity/Editor/Tools/Build

Repository: CoplayDev/unity-mcp

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- build tool call sites ---'
rg -l 'CreateBuildOptions|ParseBuildOptions|subtarget|clean_build' MCPForUnity/Editor/Tools/Build
rg -n -C 12 'CreateBuildOptions|ParseBuildOptions|subtarget|clean_build' MCPForUnity/Editor/Tools/Build --glob '*.cs' \
  | grep -E '^(MCPForUnity|--|[0-9])' | head -n 240

printf '%s\n' '--- response models and unsupported-result conventions ---'
rg -n -C 5 'class ErrorResponse|class PendingResponse|unsupported|requires Unity|warnings|warning|success =' \
  MCPForUnity/Editor --glob '*.cs' | head -n 260

Repository: CoplayDev/unity-mcp

Length of output: 32113


Make unsupported operations visible to callers.

On Unity 2020.3, lightmapCompression writes return success without applying the value. clean_build is ignored. Standalone Server requests resolve to the Player subtarget. Return explicit unsupported warnings or errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/UNITY_2020_3_COMPAT.md` around lines 76 - 80, Update the Unity 2020.3
compatibility handling for LightingSettings.lightmapCompression writes,
BuildOptions.CleanBuildCache via clean_build, and Standalone Server subtarget
requests so each unsupported operation reports an explicit warning or error to
callers instead of silently succeeding, being ignored, or falling back to
Player(0). Preserve the documented tool behavior while exposing the
compatibility limitation.

Comment thread MCPForUnity/Editor/Helpers/ProcessArgumentListCompat.cs
Comment thread MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs Outdated
Comment on lines +72 to +74
#if UNITY_2021_2_OR_NEWER
options.subtarget = subtarget;
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 5 \
  'clean_build|CleanBuildCache|subtarget|StandaloneBuildSubtarget' \
  MCPForUnity docs TestProjects \
  --glob '*.cs' --glob '*.md'

Repository: CoplayDev/unity-mcp

Length of output: 14980


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- BuildRunner.cs ---'
sed -n '1,125p' MCPForUnity/Editor/Tools/Build/BuildRunner.cs

printf '%s\n' '--- compatibility documentation ---'
sed -n '1,100p' docs/UNITY_2020_3_COMPAT.md

printf '%s\n' '--- compatibility helpers ---'
fd -i 'Unity.*Compat\.cs' MCPForUnity/Runtime/Helpers MCPForUnity/Editor 2>/dev/null | sort
rg -n -C 4 'CleanBuildCache|BuildPlayerOptions|subtarget|StandaloneBuildSubtarget' \
  MCPForUnity/Runtime/Helpers MCPForUnity/Editor/Tools/Build \
  --glob '*.cs'

Repository: CoplayDev/unity-mcp

Length of output: 16601


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- compatibility helper implementations ---'
for f in $(fd -i 'Unity.*Compat\.cs' MCPForUnity 2>/dev/null | sort); do
  echo "--- $f"
  sed -n '1,180p' "$f"
done

printf '%s\n' '--- assembly definitions and version-check tooling ---'
fd -i -E Library -E Temp -E Packages \
  '.*(asmdef|check-unity-versions\.sh)$' . 2>/dev/null | sort
rg -n -C 3 'Unity.*Compat|UNITY_2021_2_OR_NEWER|BuildOptions\.CleanBuildCache|BuildPlayerOptions' \
  MCPForUnity --glob '*.asmdef' --glob '*.cs' --glob '*.sh' | head -300

Repository: CoplayDev/unity-mcp

Length of output: 46306


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- assembly references ---'
cat MCPForUnity/Runtime/MCPForUnity.Runtime.asmdef
cat MCPForUnity/Editor/MCPForUnity.Editor.asmdef

printf '%s\n' '--- shim policy ---'
sed -n '1,90p' MCPForUnity/Runtime/Helpers/UnityCompatShims.cs

Repository: CoplayDev/unity-mcp

Length of output: 3568


Route version-dependent build APIs through a compatibility shim. Unity 2020.3 intentionally ignores clean_build and uses Player(0) for subtarget; this behavior is documented, so no warning or error is needed. Move both guards into MCPForUnity/Runtime/Helpers/Unity*Compat.cs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MCPForUnity/Editor/Tools/Build/BuildRunner.cs` around lines 72 - 74, Move the
version-dependent handling of options.subtarget and clean_build out of
BuildRunner and into the appropriate Unity*Compat.cs compatibility shim.
Preserve Unity 2020.3 behavior by ignoring clean_build and using Player(0) for
subtarget, while retaining the newer Unity behavior through the shim; remove the
direct version guards from the BuildRunner flow.

Comment thread MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs Outdated
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.12",
"com.unity.ide.vscode": "1.2.4",
"com.unity.test-framework": "1.1.29",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

manifest='TestProjects/Unity2020Compat/Packages/manifest.json'
lock='TestProjects/Unity2020Compat/Packages/packages-lock.json'

jq -r '.dependencies["com.unity.test-framework"]' "$manifest"
jq -r '.dependencies["com.coplaydev.unity-mcp"].dependencies["com.unity.test-framework"]' "$lock"
jq -r '.dependencies["com.unity.test-framework"] | {version, depth}' "$lock"

Repository: CoplayDev/unity-mcp

Length of output: 211


🏁 Script executed:

#!/bin/bash
set -euo pipefail

manifest='TestProjects/Unity2020Compat/Packages/manifest.json'
lock='TestProjects/Unity2020Compat/Packages/packages-lock.json'

printf '%s\n' '--- Unity 2020 compatibility project ---'
find 'TestProjects/Unity2020Compat' -maxdepth 3 -type f \
  \( -name 'manifest.json' -o -name 'packages-lock.json' -o -name 'package.json' -o -name 'ProjectVersion.txt' \) \
  -print

printf '%s\n' '--- Relevant package declarations ---'
cat -n "$manifest" | sed -n '1,30p'
cat -n "$lock" | sed -n '1,120p'

printf '%s\n' '--- Local package metadata ---'
rg -n -C 4 '"com\.unity\.test-framework"|test-framework' \
  TestProjects/Unity2020Compat Packages MCPForUnity 2>/dev/null || true

printf '%s\n' '--- Unity version-check script references ---'
if [ -f tools/check-unity-versions.sh ]; then
  cat -n tools/check-unity-versions.sh
else
  printf '%s\n' 'tools/check-unity-versions.sh is not present'
fi

Repository: CoplayDev/unity-mcp

Length of output: 22666


🌐 Web query:

Unity Package Manager packages-lock.json direct dependency depth manifest exact version lock file behavior Unity 2020.3

💡 Result:

In Unity 2020.3, the packages-lock.json file serves as a deterministic record of the entire dependency graph for a project, including both direct and indirect dependencies [1][2][3]. It is automatically generated and maintained by the Unity Package Manager to ensure that the exact same package versions are installed across different machines, providing reliability and performance improvements by avoiding redundant dependency resolution and downloads [1][2]. Key aspects of its behavior include: 1. Dependency Depth and Graph Storage: The lock file tracks the full dependency graph [2][3]. While the project manifest (manifest.json) stores only the top-level direct dependencies, the lock file records the specific versions of all indirect dependencies required to satisfy the project's requirements [4][5]. Because packages can have their own dependencies, the lock file structure reflects this hierarchical depth [4]. 2. Determinism and Locking: As long as a package's version in the lock file remains compatible with the constraints defined in the manifests and the project's current resolution strategy, the Package Manager will keep the package locked at that specific version [1][3]. This prevents unexpected version shifts when a project is opened on different machines [4][6]. 3. Maintenance and Manual Modification: The Package Manager exclusively manages the packages-lock.json file [1]. Users should not manually modify it, as the Package Manager will overwrite any manual changes during its next resolution pass [1]. 4. Refreshing Dependencies: If you need to force the Package Manager to recalculate the dependency graph—for example, to update indirect dependencies to the latest compatible versions—you can delete the packages-lock.json file [1]. The Package Manager will then regenerate it upon the next successful resolution [1]. 5. Source Control: It is recommended practice to commit the packages-lock.json file to source control to ensure consistent environments for all team members [4][1]. 6. Configuration: The use of the lock file is enabled by default [1][7]. If desired, it can be disabled by setting the enableLockFile property to false in the project's manifest.json, though this is generally discouraged as it can lead to non-deterministic results and increased network usage [1].

Citations:


🌐 Web query:

site:docs.unity3d.com/2020.3 "Package Manager resolves conflicts" direct dependency version dependency exact

💡 Result:

Package managers resolve version conflicts between direct and transitive (indirect) dependencies by constructing a comprehensive dependency graph that includes all requested packages [1][2]. Because a package manager can typically install only one version of a specific package at a time, it must evaluate all dependency requirements—both explicit direct dependencies defined in the project manifest and recursive transitive dependencies defined by those packages—to find a version that satisfies all constraints [1][2]. When conflicts arise, the resolution process generally follows these principles: 1. Consistency and Determinism: Package managers often use a lock file (such as packages-lock.json) to store the successfully resolved dependency graph [1][3]. This ensures that future installations produce the same results and avoids redundant computations [2][3]. 2. Version Selection Strategies: If multiple versions of a package are requested, the manager attempts to find a single version that falls within all specified version ranges [2]. If the manager cannot satisfy all constraints, it often defaults to a least-risky upgrade path, such as preferring patch updates over minor or major version changes [2][3]. 3. Configuration and Control: Users can often influence this resolution process. For example, some systems allow for the configuration of resolution strategies (e.g., forcing lowest versions or allowing higher compatible versions) to manage how strictly the manager adheres to requested versions [4][3]. While it is technically possible to resolve conflicts by explicitly adding an indirect dependency to the project manifest to override a version, this is generally considered a suboptimal practice compared to configuring resolution strategies [4]. In essence, the package manager functions as a solver that calculates a set of versions that satisfies all direct and indirect requirements simultaneously [2]. If a valid intersection of all version requirements exists, it selects a version—often the highest compatible one based on defined strategies—and locks that selection to maintain project stability [2][4][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import json
from pathlib import Path

manifest_path = Path("TestProjects/Unity2020Compat/Packages/manifest.json")
lock_path = Path("TestProjects/Unity2020Compat/Packages/packages-lock.json")
package_path = Path("MCPForUnity/package.json")

manifest = json.loads(manifest_path.read_text())
lock = json.loads(lock_path.read_text())
package = json.loads(package_path.read_text())

name = "com.unity.test-framework"
direct = manifest["dependencies"].get(name)
local_req = package["dependencies"].get(name)
locked = lock["dependencies"].get(name, {})
local_lock_req = lock["dependencies"]["com.coplaydev.unity-mcp"]["dependencies"].get(name)

print({
    "manifest_direct": direct,
    "local_package_requirement": local_req,
    "lock_local_requirement": local_lock_req,
    "lock_version": locked.get("version"),
    "lock_depth": locked.get("depth"),
    "direct_lock_entry": locked.get("depth") == 0,
    "manifest_matches_lock": direct == locked.get("version"),
    "local_requirement_matches_lock": local_req == locked.get("version"),
    "lock_requirement_matches_local_package": local_lock_req == local_req,
})
PY

Repository: CoplayDev/unity-mcp

Length of output: 453


Align the Unity Test Framework dependency graph.

manifest.json requests 1.1.29, but MCPForUnity/package.json and packages-lock.json require and resolve 1.1.31. Select one compatible version, regenerate the lock file with Unity 2020.3, and run tools/check-unity-versions.sh.

📍 Affects 2 files
  • TestProjects/Unity2020Compat/Packages/manifest.json#L8-L8 (this comment)
  • TestProjects/Unity2020Compat/Packages/packages-lock.json#L15-L16
  • TestProjects/Unity2020Compat/Packages/packages-lock.json#L93-L102
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TestProjects/Unity2020Compat/Packages/manifest.json` at line 8, Align the
Unity Test Framework dependency to one compatible version, preferably the
existing 1.1.31 required by MCPForUnity/package.json: update
TestProjects/Unity2020Compat/Packages/manifest.json and both affected
resolutions in TestProjects/Unity2020Compat/Packages/packages-lock.json (lines
15-16 and 93-102), regenerate the lock file with Unity 2020.3, then run
tools/check-unity-versions.sh.

Source: Learnings

Comment thread TestProjects/Unity2020Compat/README.md
Comment thread TestProjects/Unity2020Compat/verify_compile.cmd Outdated
Comment thread TestProjects/Unity2020Compat/verify_compile.cmd Outdated
- ProcessArgumentListCompat: correct Windows command-line quoting (backslash
  runs doubled only before quotes/at end; verbatim pass-through when unquoted)
- EncryptedFileKeyStore: implement PBKDF2-HMAC-SHA256 manually on 2020.3
  (netstandard2.1 lacks 4-arg Rfc2898DeriveBytes) so key derivation stays
  byte-identical with 2021.2+; 3-arg SHA1 would break existing ciphertext MAC
- CompatDropdownField: SetValueWithoutNotify no longer dispatches change events
- MCPForUnityEditorWindow: 2020.3 package add/remove serialized via queue
  (legacy PM accepts one in-flight request per operation)
- BuildSettingsHelper: architecture mapping fixed (0 = None, not x86_64)
- ManageBuild: 'server' subtarget rejected on <2021.2 instead of silent player
- docs: correct packages-lock.json description; test project: align
  test-framework 1.1.31, portable verify_compile.cmd (auto-detect Unity, exit
  codes, consistent log), README command block
@RoyougiShiki

Copy link
Copy Markdown
Author

Thanks for the thorough review! All actionable findings addressed in e940e904 (11 files, 231+/31-):

Fixed:

  • ProcessArgumentListCompat — rewrote quoting with the standard CommandLineToArgvW algorithm: backslashes doubled only before quotes/at end of argument, verbatim pass-through when no quoting needed.
  • EncryptedFileKeyStore — 2020.3 now implements PBKDF2-HMAC-SHA256 manually (RFC 2898) since netstandard2.1 lacks the 4-arg Rfc2898DeriveBytes; key derivation is byte-identical with the 2021.2+ path, so existing ciphertext keeps validating.
  • CompatDropdownField.SetValueWithoutNotify — no longer dispatches change events on 2020.3 (matches native 2021.2+ behavior).
  • MCPForUnityEditorWindow — legacy (2020.3) package add/remove now serialized through a queue; next request starts only after the previous completes.
  • BuildSettingsHelper — architecture mapping corrected: 0 = None (not x86_64); x86_64 removed from valid inputs.
  • ManageBuildsubtarget: "server" now returns an explicit error on <2021.2 instead of silently building player.
  • docs/UNITY_2020_3_COMPAT.md — corrected to document packages-lock.json parsing (not Client.List polling).
  • Test project — test-framework aligned to 1.1.31 across manifest/lock; verify_compile.cmd rewritten (portable: %~dp0 + auto-detect Unity path or arg, exit codes, consistent log name, enforces error CS absence + clean batchmode exit); README command block fixed.

Deferred with rationale (kept as-is for this PR):

  • Centralizing version guards into a Unity*Compat.cs shim (ManageBuild/BuildRunner/BuildTargetMapping): agreed it's the right long-term shape, but it's a cross-cutting refactor of upstream-owned files; keeping the #if guards local makes the 2020.3 delta easier to review and rebase. Happy to follow up with a shim refactor PR if maintainers prefer.
  • lightmapCompression / clean_build silent skip on 2020.3: both are documented in the compat doc as APIs that don't exist before 2021.2; failing loudly would break existing tool callers on 2020.3. (ManageBuild's server subtarget is different — it would silently produce a wrong build, hence the explicit error there.)
  • Docstring coverage warning: this PR is mechanical compatibility rewriting; docstrings were not added to unchanged logic. Can add if required by repo policy.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs`:
- Around line 106-109: Correct the target framework reference in the comment
above the manual PBKDF2-HMAC-SHA256 implementation: identify Unity 2020.3 as
using netstandard2.0 instead of netstandard2.1, while preserving the explanation
of why the manual derivation is required.

In `@MCPForUnity/Editor/Tools/ManageBuild.cs`:
- Around line 253-259: Update the build-target flow around the active-target
return and subtarget handling so `subtarget` is validated and applied before the
short circuit. On Unity 2020.3, reject `server` requests before returning for an
already-active target; on Unity 2021.2+, apply both `server` and `player`
through `standaloneBuildSubtarget`. Keep the existing `SwitchActiveBuildTarget`
skip only when the target is already active.

In `@TestProjects/Unity2020Compat/verify_compile.cmd`:
- Around line 45-46: Update verify_compile.cmd after the Unity invocation and
UNITY_STATUS capture to fail immediately when UNITY_STATUS is nonzero, before
evaluating any log markers or reporting PASS. Preserve the existing log
validation for successful Unity executions.
- Line 27: Update the UNITY_EXE detection condition to use %%~E for both the
existence check and assignment, ensuring the stored executable path excludes
surrounding quotes and later command usage does not produce double-quoted paths.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e196bae5-ec85-40f8-b1a0-50b4e8ae6bce

📥 Commits

Reviewing files that changed from the base of the PR and between 000fde5 and e940e90.

📒 Files selected for processing (11)
  • MCPForUnity/Editor/Helpers/ProcessArgumentListCompat.cs
  • MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs
  • MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs
  • MCPForUnity/Editor/Tools/ManageBuild.cs
  • MCPForUnity/Editor/Windows/Components/CompatDropdownField.cs
  • MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs
  • TestProjects/Unity2020Compat/Packages/manifest.json
  • TestProjects/Unity2020Compat/Packages/packages-lock.json
  • TestProjects/Unity2020Compat/README.md
  • TestProjects/Unity2020Compat/verify_compile.cmd
  • docs/UNITY_2020_3_COMPAT.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • TestProjects/Unity2020Compat/README.md
  • docs/UNITY_2020_3_COMPAT.md
  • TestProjects/Unity2020Compat/Packages/packages-lock.json
  • TestProjects/Unity2020Compat/Packages/manifest.json
  • MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs
  • MCPForUnity/Editor/Tools/Build/BuildSettingsHelper.cs
  • MCPForUnity/Editor/Windows/Components/CompatDropdownField.cs

Comment thread MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs Outdated
Comment thread MCPForUnity/Editor/Tools/ManageBuild.cs
Comment thread TestProjects/Unity2020Compat/verify_compile.cmd Outdated
Comment thread TestProjects/Unity2020Compat/verify_compile.cmd
- verify_compile.cmd: use %%~E to strip quotes from detected Unity path
  (%%E kept surrounding quotes -> double-quoted executable); fail when
  Unity exits nonzero before accepting log markers
- ManageBuild: process subtarget before the active-target short-circuit so
  a 'server' request on <2021.2 errors even when platform is already active
- EncryptedFileKeyStore: correct comment (netstandard2.0, not 2.1)
@RoyougiShiki

Copy link
Copy Markdown
Author

Second round addressed in df74f8f0:

  • verify_compile.cmd: %%~E now strips the surrounding quotes when detecting the Unity executable (%%E produced ""C:\...\Unity.exe""); Unity's exit code is now checked before accepting log markers, so a failed invocation can't report PASS against a stale log.
  • ManageBuild: subtarget processing moved before the active-target short-circuit — a server request on Unity < 2021.2 now returns the explicit unsupported error even when the platform is already active (previously it silently returned "Already on this platform").
  • EncryptedFileKeyStore: comment corrected to netstandard2.0 (Unity 2020.3 API compatibility level), avoiding future misuse of 2.1-only APIs.

@RoyougiShiki

Copy link
Copy Markdown
Author

These four comments reference the pre-df74f8f0 state — all four were already fixed in that commit:

  • verify_compile.cmd %%E quotes → now %%~E (line 27)
  • verify_compile.cmd exit-code check → Unity's UNITY_STATUS is checked before accepting log markers (line 48)
  • ManageBuild subtarget ordering → subtarget processing now runs before the active-target short-circuit (line 235)
  • EncryptedFileKeyStore netstandard comment → corrected to netstandard2.0 (line 106)

Verified compiling on Unity 2020.3.24f1 (0 errors / 0 warnings). Ready for the next review round on df74f8f0.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@TestProjects/Unity2020Compat/verify_compile.cmd`:
- Line 27: Quote the operand of the if exist check in the %%E loop so paths
containing spaces are handled correctly, while keeping the UNITY_EXE assignment
based on the unquoted %%~E value.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f3d3cf43-157e-46d9-a492-8a9ae9f6df12

📥 Commits

Reviewing files that changed from the base of the PR and between e940e90 and df74f8f.

📒 Files selected for processing (3)
  • MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs
  • MCPForUnity/Editor/Tools/ManageBuild.cs
  • TestProjects/Unity2020Compat/verify_compile.cmd
🚧 Files skipped from review as they are similar to previous changes (2)
  • MCPForUnity/Editor/Tools/ManageBuild.cs
  • MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs

Comment thread TestProjects/Unity2020Compat/verify_compile.cmd Outdated
%%~E strips quotes for the assignment; the if exist check needs its own
quotes to handle spaces in default Hub paths (C:\Program Files\...).
Verified with a space-path test on cmd.exe.
@RoyougiShiki

Copy link
Copy Markdown
Author

Addressed in 775f15b1: the if exist operand is now quoted (if exist "%%~E"), keeping the assignment unquoted — handles spaces in default Hub install paths (C:\Program Files\...). Verified on cmd.exe with a space-containing test path.

(Note: Blinter's E024 on %~E is a false positive — %%~E is the standard for-variable quote-stripping syntax, not a %1-style parameter modifier.)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
TestProjects/Unity2020Compat/verify_compile.cmd (2)

9-9: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented exit code contract.

Exit code 1 also covers Unity startup failure, a missing log, and an unclean shutdown. Document it as 1 = verification failed, or list the individual failure cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TestProjects/Unity2020Compat/verify_compile.cmd` at line 9, Update the
exit-code documentation in verify_compile.cmd to state that code 1 means
verification failed, covering compile errors, Unity startup failure, missing
logs, and unclean shutdown; retain the existing meanings for codes 0 and 2.

17-20: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Validate that the selected editor is Unity 2020.3.

The command-line argument and UNITY_EDITOR value are accepted after only an existence check. A caller can provide Unity 2021.3 or a newer editor, and the script can report success without compiling under Unity 2020.3. Reject editors outside the 2020.3 line, or verify the editor version from its output before running the check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TestProjects/Unity2020Compat/verify_compile.cmd` around lines 17 - 20, Update
the editor-selection logic in verify_compile.cmd to validate that the chosen
UNITY_EXE, whether supplied by %~1 or UNITY_EDITOR, is Unity 2020.3 before
compiling. Reject or fail clearly for other editor versions, including newer
releases, rather than proceeding with verification.
🧹 Nitpick comments (2)
TestProjects/Unity2020Compat/verify_compile.cmd (2)

45-46: 🩺 Stability & Availability | 🔵 Trivial | 🏗️ Heavy lift

Provide a timeout for the Unity process.

Line 45 blocks until Unity exits. If Unity hangs during import, licensing, or project reload, the verification job can hang indefinitely. Confirm that the calling CI job has an outer timeout, or add a timeout and process-termination path here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TestProjects/Unity2020Compat/verify_compile.cmd` around lines 45 - 46, Update
the Unity invocation in the verification script to enforce a finite timeout and
terminate the Unity process when it exceeds that limit, while preserving capture
of its exit status in UNITY_STATUS. If timeout handling is provided by the
calling CI job instead, confirm and rely on that documented outer timeout rather
than leaving the process unbounded.

41-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Run the cross-version compatibility check before merge.

This script validates one selected editor. Run tools/check-unity-versions.sh to compile-check the supported Unity version matrix, including newer Unity versions.

Based on learnings: “When modifying Unity version shims or gated code, run tools/check-unity-versions.sh to compile-check across the CI matrix before committing.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TestProjects/Unity2020Compat/verify_compile.cmd` around lines 41 - 71, Run
tools/check-unity-versions.sh to compile-check the complete supported Unity
version matrix, including newer editors, before committing or merging changes to
Unity compatibility code; keep verify_compile.cmd focused on validating its
selected editor.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@TestProjects/Unity2020Compat/verify_compile.cmd`:
- Line 9: Update the exit-code documentation in verify_compile.cmd to state that
code 1 means verification failed, covering compile errors, Unity startup
failure, missing logs, and unclean shutdown; retain the existing meanings for
codes 0 and 2.
- Around line 17-20: Update the editor-selection logic in verify_compile.cmd to
validate that the chosen UNITY_EXE, whether supplied by %~1 or UNITY_EDITOR, is
Unity 2020.3 before compiling. Reject or fail clearly for other editor versions,
including newer releases, rather than proceeding with verification.

---

Nitpick comments:
In `@TestProjects/Unity2020Compat/verify_compile.cmd`:
- Around line 45-46: Update the Unity invocation in the verification script to
enforce a finite timeout and terminate the Unity process when it exceeds that
limit, while preserving capture of its exit status in UNITY_STATUS. If timeout
handling is provided by the calling CI job instead, confirm and rely on that
documented outer timeout rather than leaving the process unbounded.
- Around line 41-71: Run tools/check-unity-versions.sh to compile-check the
complete supported Unity version matrix, including newer editors, before
committing or merging changes to Unity compatibility code; keep
verify_compile.cmd focused on validating its selected editor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95bdfbab-b565-482a-98b6-0333e221e968

📥 Commits

Reviewing files that changed from the base of the PR and between df74f8f and 775f15b.

📒 Files selected for processing (1)
  • TestProjects/Unity2020Compat/verify_compile.cmd

…ix note

- Exit code 1 documented as 'verification failed' (compile errors, startup
  failure, missing log, unclean exit)
- Non-2020.3 editors get a clear warning (path-based 2020.3 check) instead of
  silently passing - this project validates the 2020.3 floor
- PASS output notes tools/check-unity-versions.sh for the full matrix
@RoyougiShiki

Copy link
Copy Markdown
Author

Round 4 addressed in 639279b4:

  • Exit-code contract — documented: 1 = verification failed (compile errors, Unity startup failure, missing log, unclean exit); 0/2 meanings retained.
  • Editor version check — the chosen editor (arg or UNITY_EDITOR) is now checked for a 2020.3 path component with a clear warning when it isn't. Not a hard reject: passing a newer editor is a legitimate forward-compat check, but the warning makes it explicit that 2020.3-floor validation requires the 2020.3 editor.
  • Matrix note — PASS output now points to tools/check-unity-versions.sh for the full supported-version matrix.

Skipped with rationale: in-script timeout/termination for the Unity process — this script is a local/CI helper where the caller already bounds the job (our runs use an outer timeout); adding start /w + taskkill bookkeeping inside the .cmd would add failure modes without real coverage. Happy to add it if a CI job needs to rely on the script alone.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant