Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions MCPForUnity/Editor/Tools/ManageScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1933,15 +1933,8 @@ string namespaceName
/// </summary>
private static ValidationLevel GetValidationLevelFromGUI()
{
string savedLevel = EditorPrefs.GetString("MCPForUnity_ScriptValidationLevel", "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);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions deploy-dev.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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:
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%"=="" (
Expand Down
24 changes: 19 additions & 5 deletions restore-dev.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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): "
Expand All @@ -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...
)
Comment on lines +135 to 146
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Runtime restoration block successfully implements PR objective.

The new Runtime restoration logic correctly mirrors the Editor block with appropriate error handling and messaging. This addresses the PR objective to include the runtime folder in the restore workflow.

Verify that the backup script (backup-dev.bat) has been updated to create the UnityBridge\Runtime directory structure, ensuring backups contain the necessary Runtime files for successful restoration.


🏁 Script executed:

#!/bin/bash
# Description: Verify backup script creates UnityBridge\Runtime directory structure

# Search for Runtime backup logic in backup-dev.bat
rg -n "Runtime|UnityBridge" -g "backup-dev.bat" -C3

Length of output: 148


🏁 Script executed:

#!/bin/bash
# Description: Locate and examine backup-dev.bat for Runtime directory handling

# First, find the backup-dev.bat file
echo "=== Locating backup-dev.bat ==="
fd -n "backup-dev.bat"

# Then search for Runtime-related content
echo ""
echo "=== Searching for Runtime in backup script ==="
rg -n "Runtime" -C3

Length of output: 85453


🏁 Script executed:

#!/bin/bash
# Description: Locate backup-dev.bat and verify Runtime backup logic

# Find backup-dev.bat using correct fd syntax
echo "=== Finding backup-dev.bat ==="
fd "backup-dev.bat"

# Once located, examine its contents for UnityBridge\Runtime
echo ""
echo "=== Examining backup-dev.bat for Runtime backup logic ==="
find . -name "backup-dev.bat" -type f -exec cat {} \;

Length of output: 89


🏁 Script executed:

#!/bin/bash
# Description: Search for backup-related scripts

echo "=== All .bat files in repository ==="
find . -name "*.bat" -type f

echo ""
echo "=== All .sh and .ps1 files ==="
find . -name "*.sh" -o -name "*.ps1" | head -20

echo ""
echo "=== Search for 'backup' in script filenames ==="
find . -type f \( -name "*backup*" \)

echo ""
echo "=== Check if restore-dev.bat references backup-dev.bat ==="
grep -n "backup-dev" restore-dev.bat 2>/dev/null || echo "No reference found"

Length of output: 266


Backup script does not exist — restore functionality cannot work.

The restore block at lines 135-146 assumes backups exist at %SELECTED_BACKUP%\UnityBridge\Runtime, but there is no backup-dev.bat in the repository and no backup functionality at all. The Runtime restore code will always skip with the warning message, rendering it non-functional.

Implement backup functionality (at minimum, a backup-dev.bat script that creates backups of %PACKAGE_CACHE_PATH%\Runtime to the backup location) to enable the restore workflow.

🤖 Prompt for AI Agents
In restore-dev.bat around lines 135 to 146, the restore assumes a backup exists
at %SELECTED_BACKUP%\UnityBridge\Runtime but no backup script or backups are
provided; add a new backup-dev.bat that creates and verifies backups so restore
can work: implement a batch that validates %PACKAGE_CACHE_PATH%\Runtime exists,
creates the %BACKUP_ROOT% (or %SELECTED_BACKUP%) folder if missing, copies the
Runtime folder into a timestamped subfolder (or into the chosen backup path)
using robocopy/xcopy with proper flags, returns a non-zero exit code and prints
an error on failure, and documents expected environment variables; ensure the
backup script sets/exports the same variables used by restore-dev.bat and exits
successfully when backup completes so the restore block can find and restore the
files.


:: Restore Python Server
Expand Down