From b80b9abe46adb822e31141478572777047d7949f Mon Sep 17 00:00:00 2001 From: Shutong Wu <51266340+Scriptwonder@users.noreply.github.com> Date: Sat, 25 Oct 2025 01:13:58 -0400 Subject: [PATCH 1/2] Update .Bat file and Bug fix on ManageScript * Update the .Bat file to include runtime folder * Fix the inconsistent EditorPrefs variable so the GUI change on Script Validation could cause real change. --- MCPForUnity/Editor/Tools/ManageScript.cs | 2 +- deploy-dev.bat | 4 ++-- restore-dev.bat | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/MCPForUnity/Editor/Tools/ManageScript.cs b/MCPForUnity/Editor/Tools/ManageScript.cs index 51669c657..db5679c07 100644 --- a/MCPForUnity/Editor/Tools/ManageScript.cs +++ b/MCPForUnity/Editor/Tools/ManageScript.cs @@ -1933,7 +1933,7 @@ string namespaceName /// private static ValidationLevel GetValidationLevelFromGUI() { - string savedLevel = EditorPrefs.GetString("MCPForUnity_ScriptValidationLevel", "standard"); + string savedLevel = EditorPrefs.GetString("MCPForUnity.ValidationLevel", "standard"); return savedLevel.ToLower() switch { "basic" => ValidationLevel.Basic, diff --git a/deploy-dev.bat b/deploy-dev.bat index 60a398bd9..300856d3d 100644 --- a/deploy-dev.bat +++ b/deploy-dev.bat @@ -11,7 +11,7 @@ set "SCRIPT_DIR=%~dp0" set "BRIDGE_SOURCE=%SCRIPT_DIR%MCPForUnity" set "SERVER_SOURCE=%SCRIPT_DIR%MCPForUnity\UnityMcpServer~\src" set "DEFAULT_BACKUP_DIR=%USERPROFILE%\Desktop\unity-mcp-backup" -set "DEFAULT_SERVER_PATH=%LOCALAPPDATA%\Programs\UnityMCP\UnityMcpServer\src" +set "DEFAULT_SERVER_PATH=%LOCALAPPDATA%\UnityMCP\UnityMcpServer\src" :: Get user inputs echo Please provide the following paths: @@ -19,7 +19,7 @@ echo. :: Package cache location echo Unity Package Cache Location: -echo Example: X:\UnityProject\Library\PackageCache\com.coplaydev.unity-mcp@1.0.0 +echo Example: X:\Unity\Projects\UnityMCPTestbed2\Library\PackageCache\com.coplaydev.unity-mcp@4c106125b342 set /p "PACKAGE_CACHE_PATH=Enter Unity package cache path: " if "%PACKAGE_CACHE_PATH%"=="" ( diff --git a/restore-dev.bat b/restore-dev.bat index 6f68be0ba..15184412c 100644 --- a/restore-dev.bat +++ b/restore-dev.bat @@ -102,7 +102,8 @@ echo =============================================== echo WARNING: This will overwrite current files! echo =============================================== echo Restoring from: %SELECTED_BACKUP% -echo Unity Bridge target: %PACKAGE_CACHE_PATH%\Editor +echo Unity Bridge Editor target: %PACKAGE_CACHE_PATH%\Editor +echo Unity Bridge Runtime target: %PACKAGE_CACHE_PATH%\Runtime echo Python Server target: %SERVER_PATH% echo. set /p "confirm=Continue with restore? (y/N): " @@ -119,16 +120,29 @@ echo =============================================== :: Restore Unity Bridge if exist "%SELECTED_BACKUP%\UnityBridge\Editor" ( - echo Restoring Unity Bridge files... + echo Restoring Unity Bridge Editor files... rd /s /q "%PACKAGE_CACHE_PATH%\Editor" 2>nul xcopy "%SELECTED_BACKUP%\UnityBridge\Editor\*" "%PACKAGE_CACHE_PATH%\Editor\" /E /I /Y > nul if !errorlevel! neq 0 ( - echo Error: Failed to restore Unity Bridge files + echo Error: Failed to restore Unity Bridge Editor files pause exit /b 1 ) ) else ( - echo Warning: No Unity Bridge backup found, skipping... + echo Warning: No Unity Bridge Editor backup found, skipping... +) + +if exist "%SELECTED_BACKUP%\UnityBridge\Runtime" ( + echo Restoring Unity Bridge Runtime files... + rd /s /q "%PACKAGE_CACHE_PATH%\Runtime" 2>nul + xcopy "%SELECTED_BACKUP%\UnityBridge\Runtime\*" "%PACKAGE_CACHE_PATH%\Runtime\" /E /I /Y > nul + if !errorlevel! neq 0 ( + echo Error: Failed to restore Unity Bridge Runtime files + pause + exit /b 1 + ) +) else ( + echo Warning: No Unity Bridge Runtime backup found, skipping... ) :: Restore Python Server From 4e9604f249cf9e13fd0750bef747f84ad9c35efa Mon Sep 17 00:00:00 2001 From: Shutong Wu <51266340+Scriptwonder@users.noreply.github.com> Date: Sat, 25 Oct 2025 11:19:11 -0400 Subject: [PATCH 2/2] Further changes String to Int for consistency --- MCPForUnity/Editor/Tools/ManageScript.cs | 11 ++--------- restore-dev.bat | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/MCPForUnity/Editor/Tools/ManageScript.cs b/MCPForUnity/Editor/Tools/ManageScript.cs index db5679c07..b5cbbb1d3 100644 --- a/MCPForUnity/Editor/Tools/ManageScript.cs +++ b/MCPForUnity/Editor/Tools/ManageScript.cs @@ -1933,15 +1933,8 @@ string namespaceName /// private static ValidationLevel GetValidationLevelFromGUI() { - string savedLevel = EditorPrefs.GetString("MCPForUnity.ValidationLevel", "standard"); - return savedLevel.ToLower() switch - { - "basic" => ValidationLevel.Basic, - "standard" => ValidationLevel.Standard, - "comprehensive" => ValidationLevel.Comprehensive, - "strict" => ValidationLevel.Strict, - _ => ValidationLevel.Standard // Default fallback - }; + int savedLevel = EditorPrefs.GetInt("MCPForUnity.ValidationLevel", (int)ValidationLevel.Standard); + return (ValidationLevel)Mathf.Clamp(savedLevel, 0, 3); } /// diff --git a/restore-dev.bat b/restore-dev.bat index 15184412c..81311f6c2 100644 --- a/restore-dev.bat +++ b/restore-dev.bat @@ -11,7 +11,7 @@ echo. :: Configuration set "DEFAULT_BACKUP_DIR=%USERPROFILE%\Desktop\unity-mcp-backup" -set "DEFAULT_SERVER_PATH=%LOCALAPPDATA%\Programs\UnityMCP\UnityMcpServer\src" +set "DEFAULT_SERVER_PATH=%LOCALAPPDATA%\UnityMCP\UnityMcpServer\src" :: Get user inputs echo Please provide the following paths: