Skip to content

Commit df74f8f

Browse files
committed
fix: second-round CodeRabbit findings
- 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)
1 parent e940e90 commit df74f8f

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

MCPForUnity/Editor/Security/SecureKeyStore/EncryptedFileKeyStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void DeriveKeys(out byte[] encKey, out byte[] macKey)
103103
Buffer.BlockCopy(material, 32, macKey, 0, 32);
104104
}
105105
#else
106-
// Unity 2020.3 (netstandard2.1) has no 4-arg Rfc2898DeriveBytes overload, so
106+
// Unity 2020.3 (netstandard2.0 profile) has no 4-arg Rfc2898DeriveBytes overload, so
107107
// implement PBKDF2-HMAC-SHA256 (RFC 2898) manually to keep key derivation
108108
// byte-identical with the 2021.2+ path (a 3-arg SHA1 derivation would make
109109
// existing ciphertext fail MAC validation).

MCPForUnity/Editor/Tools/ManageBuild.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,8 @@ private static object HandlePlatform(ToolParams p)
232232
return new ErrorResponse(
233233
$"Platform '{target}' is not installed. Install it via Unity Hub.");
234234

235-
if (EditorUserBuildSettings.activeBuildTarget == target)
236-
return new SuccessResponse("Already on this platform.", new
237-
{
238-
target = target.ToString()
239-
});
240-
241-
// Capture previous target before switching
242-
string previousTarget = EditorUserBuildSettings.activeBuildTarget.ToString();
243-
235+
// Process subtarget before the active-target short-circuit so a "server"
236+
// request on Unity < 2021.2 errors out even when the platform is already active.
244237
string subtargetStr = p.Get("subtarget");
245238
if (!string.IsNullOrEmpty(subtargetStr))
246239
{
@@ -259,6 +252,15 @@ private static object HandlePlatform(ToolParams p)
259252
#endif
260253
}
261254

255+
if (EditorUserBuildSettings.activeBuildTarget == target)
256+
return new SuccessResponse("Already on this platform.", new
257+
{
258+
target = target.ToString()
259+
});
260+
261+
// Capture previous target before switching
262+
string previousTarget = EditorUserBuildSettings.activeBuildTarget.ToString();
263+
262264
// SwitchActiveBuildTarget is synchronous — blocks until reimport completes
263265
EditorUserBuildSettings.SwitchActiveBuildTarget(group, target);
264266

TestProjects/Unity2020Compat/verify_compile.cmd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if not "%~1"=="" (
2424
"C:\Program Files\Unity\Hub\Editor\2020.3.*\Editor\Unity.exe"
2525
"%ProgramFiles%\Unity\Hub\Editor\2020.3.*\Editor\Unity.exe"
2626
) do (
27-
if not defined UNITY_EXE if exist %%E set "UNITY_EXE=%%E"
27+
if not defined UNITY_EXE if exist %%~E set "UNITY_EXE=%%~E"
2828
)
2929
)
3030

@@ -45,6 +45,11 @@ del /q "%LOG_FILE%" 2>nul
4545
"%UNITY_EXE%" -batchmode -nographics -quit -projectPath "%PROJECT_DIR%" -logFile "%LOG_FILE%"
4646
set "UNITY_STATUS=%ERRORLEVEL%"
4747

48+
if not "%UNITY_STATUS%"=="0" (
49+
echo [verify] FAILED: Unity exited with status %UNITY_STATUS%.
50+
exit /b 1
51+
)
52+
4853
if not exist "%LOG_FILE%" (
4954
echo [verify] No log file produced (Unity may have failed to start).
5055
exit /b 1

0 commit comments

Comments
 (0)