Fix HTTP/Stdio Transport UX and Test Bug (#530)

* refactor: Split ParseColorOrDefault into two overloads and change default to Color.white

* Auto-format Python code

* Remove unused Python module

* Refactored VFX functionality into multiple files

Tested everything, works like a charm

* Rename ManageVfx folder to just Vfx

We know what it's managing

* Clean up whitespace on plugin tools and resources

* Make ManageGameObject less of a monolith by splitting it out into different files

* Remove obsolete FindObjectByInstruction method

We also update the namespace for ManageVFX

* Add local test harness for fast developer iteration

Scripts for running the NL/T/GO test suites locally against a GUI Unity
Editor, complementing the CI workflows in .github/workflows/.

Benefits:
- 10-100x faster than CI (no Docker startup)
- Real-time Unity console debugging
- Single test execution for rapid iteration
- Auto-detects HTTP vs stdio transport

Usage:
  ./scripts/local-test/setup.sh           # One-time setup
  ./scripts/local-test/quick-test.sh NL-0 # Run single test
  ./scripts/local-test/run-nl-suite-local.sh  # Full suite

See scripts/local-test/README.md for details.

Also updated .gitignore to:
- Allow scripts/local-test/ to be tracked
- Ignore generated artifacts (reports/*.xml, .claude/local/, .unity-mcp/)

* Fix issue #525: Save dirty scenes for all test modes

Move SaveDirtyScenesIfNeeded() call outside the PlayMode conditional
so EditMode tests don't get blocked by Unity's "Save Scene" modal dialog.

This prevents MCP from timing out when running EditMode tests with unsaved
scene changes.

* refactor: Consolidate editor state resources into single canonical implementation

Merged EditorStateV2 into EditorState, making get_editor_state the canonical resource. Updated Unity C# to use EditorStateCache directly. Enhanced Python implementation with advice/staleness enrichment, external changes detection, and instance ID inference. Removed duplicate EditorStateV2 resource and legacy fallback mapping.

* Validate editor state with Pydantic models in both C# and Python

Added strongly-typed Pydantic models for EditorStateV2 schema in Python and corresponding C# classes with JsonProperty attributes. Updated C# to serialize using typed classes instead of anonymous objects. Python now validates the editor state payload before returning it, catching schema mismatches early.

* Consolidate run_tests and run_tests_async into single async implementation

Merged run_tests_async into run_tests, making async job-based execution the default behavior. Removed synchronous blocking test execution. Updated RunTests.cs to start test jobs immediately and return job_id for polling. Changed TestJobManager methods to internal visibility. Updated README to reflect single run_tests_async tool. Python implementation now uses async job pattern exclusively.

* Validate test job responses with Pydantic models in Python

* Change resources URI from unity:// to mcpforunity://

It should reduce conflicts with other Unity MCPs that users try, and to comply with Unity's requests regarding use of their company and product name

* Update README with all tools + better listing for resources

* Update other references to resources

* Updated translated doc - unfortunately I cannot verify

* Update the Chinese translation of the dev docks

* Change menu item from Setup Window to Local Setup Window

We now differentiate whether it's HTTP local or remote

* Fix URIs for menu items and tests

* Shouldn't have removed it

* fix: add missing FAST_FAIL_TIMEOUT constant in PluginHub

The FAST_FAIL_TIMEOUT class attribute was referenced on line 149 but never
defined, causing AttributeError on every ping attempt. This error was silently
caught by the broad 'except Exception' handler, causing all fast-fail commands
(read_console, get_editor_state, ping) to fail after 6 seconds of retries with
'ping not answered' error.

Added FAST_FAIL_TIMEOUT = 10 to define a 10-second timeout for fast-fail
commands, matching the intent of the existing fast-fail infrastructure.

* feat(ScriptableObject): enhance dry-run validation for AnimationCurve and Quaternion

Dry-run validation now validates value formats, not just property existence:

- AnimationCurve: Validates structure ({keys:[...]} or direct array), checks
  each keyframe is an object, validates numeric fields (time, value, inSlope,
  outSlope, inWeight, outWeight) and integer fields (weightedMode)
- Quaternion: Validates array length (3 for Euler, 4 for raw) or object
  structure ({x,y,z,w} or {euler:[x,y,z]}), ensures all components are numeric

Refactored shared validation helpers into appropriate locations:
- ParamCoercion: IsNumericToken, ValidateNumericField, ValidateIntegerField
- VectorParsing: ValidateAnimationCurveFormat, ValidateQuaternionFormat

Added comprehensive XML documentation clarifying keyframe field defaults
(all default to 0 except as noted).

Added 5 new dry-run validation tests covering valid and invalid formats
for both AnimationCurve and Quaternion properties.

* test: fix integration tests after merge

- test_refresh_unity_retry_recovery: Mock now handles both refresh_unity and
  get_editor_state commands (refresh_unity internally calls get_editor_state
  when wait_for_ready=True)
- test_run_tests_async_forwards_params: Mock response now includes required
  'mode' field for RunTestsStartResponse Pydantic validation
- test_get_test_job_forwards_job_id: Updated to handle GetTestJobResponse as
  Pydantic model instead of dict (use model_dump() for assertions)

* Update warning message to apply to all test modes

Follow-up to PR #527: Since SaveDirtyScenesIfNeeded() now runs for all test modes, update the warning message to say 'tests' instead of 'PlayMode tests'.

* feat(run_tests): add wait_timeout to get_test_job to avoid client loop detection

When polling for test completion, MCP clients like Cursor can detect the
repeated get_test_job calls as 'looping' and terminate the agent.

Added wait_timeout parameter that makes the server wait internally for tests
to complete (polling Unity every 2s) before returning. This dramatically
reduces client-side tool calls from 10-20 down to 1-2, avoiding loop detection.

Usage: get_test_job(job_id='xxx', wait_timeout=30)
- Returns immediately if tests complete within timeout
- Returns current status if timeout expires (client can call again)
- Recommended: 30-60 seconds

* fix: use Pydantic attribute access in test_run_tests_async for merge compatibility

* revert: remove local test harness - will be submitted in separate PR

* fix: stdio transport survives test runs without UI flicker

Root cause: WriteToConfigTests.TearDown() was unconditionally deleting
UseHttpTransport EditorPref even when tests were skipped on Windows
(NUnit runs TearDown even after Assert.Ignore).

Changes:
- Fix WriteToConfigTests to save/restore prefs instead of deleting
- Add centralized ShouldForceUvxRefresh() for local dev path detection
- Clean stale Python build/ artifacts before client configuration
- Improve reload handler flag management to prevent stuck Resuming state
- Show Resuming status during stdio bridge restart
- Initialize client config display on window open
- Add DevModeForceServerRefresh to EditorPrefs window known types

---------

Co-authored-by: Marcus Sanatan <msanatan@gmail.com>
Co-authored-by: Scott Jennings <scott.jennings+CIGINT@cloudimperiumgames.com>
main
dsarno 2026-01-07 19:33:22 -08:00 committed by GitHub
parent 34b6a11eb6
commit cb4e2c9ef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 193 additions and 52 deletions

View File

@ -467,8 +467,8 @@ namespace MCPForUnity.Editor.Clients
else
{
var (uvxPath, gitUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = GetDevModeForceRefresh();
string devFlags = devForceRefresh ? "--no-cache --refresh " : string.Empty;
// Use central helper that checks both DevModeForceServerRefresh AND local path detection.
string devFlags = AssetPathUtility.ShouldForceUvxRefresh() ? "--no-cache --refresh " : string.Empty;
args = $"mcp add --transport stdio UnityMCP -- \"{uvxPath}\" {devFlags}--from \"{gitUrl}\" {packageName}";
}
@ -586,8 +586,8 @@ namespace MCPForUnity.Editor.Clients
}
string gitUrl = AssetPathUtility.GetMcpServerGitUrl();
bool devForceRefresh = GetDevModeForceRefresh();
string devFlags = devForceRefresh ? "--no-cache --refresh " : string.Empty;
// Use central helper that checks both DevModeForceServerRefresh AND local path detection.
string devFlags = AssetPathUtility.ShouldForceUvxRefresh() ? "--no-cache --refresh " : string.Empty;
return "# Register the MCP server with Claude Code:\n" +
$"claude mcp add --transport stdio UnityMCP -- \"{uvxPath}\" {devFlags}--from \"{gitUrl}\" mcp-for-unity\n\n" +
@ -597,12 +597,6 @@ namespace MCPForUnity.Editor.Clients
"claude mcp list # Only works when claude is run in the project's directory";
}
private static bool GetDevModeForceRefresh()
{
try { return EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); }
catch { return false; }
}
public override IList<string> GetInstallationSteps() => new List<string>
{
"Ensure Claude CLI is installed",

View File

@ -186,6 +186,88 @@ namespace MCPForUnity.Editor.Helpers
return (uvxPath, fromUrl, packageName);
}
/// <summary>
/// Determines whether uvx should use --no-cache --refresh flags.
/// Returns true if DevModeForceServerRefresh is enabled OR if the server URL is a local path.
/// Local paths (file:// or absolute) always need fresh builds to avoid stale uvx cache.
/// </summary>
public static bool ShouldForceUvxRefresh()
{
bool devForceRefresh = false;
try { devForceRefresh = EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); } catch { }
if (devForceRefresh)
return true;
// Auto-enable force refresh when using a local path override.
return IsLocalServerPath();
}
/// <summary>
/// Returns true if the server URL is a local path (file:// or absolute path).
/// </summary>
public static bool IsLocalServerPath()
{
string fromUrl = GetMcpServerGitUrl();
if (string.IsNullOrEmpty(fromUrl))
return false;
// Check for file:// protocol or absolute local path
return fromUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase) ||
System.IO.Path.IsPathRooted(fromUrl);
}
/// <summary>
/// Gets the local server path if GitUrlOverride points to a local directory.
/// Returns null if not using a local path.
/// </summary>
public static string GetLocalServerPath()
{
if (!IsLocalServerPath())
return null;
string fromUrl = GetMcpServerGitUrl();
if (fromUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
{
// Strip file:// prefix
fromUrl = fromUrl.Substring(7);
}
return fromUrl;
}
/// <summary>
/// Cleans stale Python build artifacts from the local server path.
/// This is necessary because Python's build system doesn't remove deleted files from build/,
/// and the auto-discovery mechanism will pick up old .py files causing ghost resources/tools.
/// </summary>
/// <returns>True if cleaning was performed, false if not applicable or failed.</returns>
public static bool CleanLocalServerBuildArtifacts()
{
string localPath = GetLocalServerPath();
if (string.IsNullOrEmpty(localPath))
return false;
// Clean the build/ directory which can contain stale .py files
string buildPath = System.IO.Path.Combine(localPath, "build");
if (System.IO.Directory.Exists(buildPath))
{
try
{
System.IO.Directory.Delete(buildPath, recursive: true);
McpLog.Info($"Cleaned stale build artifacts from: {buildPath}");
return true;
}
catch (Exception ex)
{
McpLog.Warn($"Failed to clean build artifacts: {ex.Message}");
return false;
}
}
return false;
}
/// <summary>
/// Gets the package version from package.json
/// </summary>

View File

@ -17,22 +17,11 @@ namespace MCPForUnity.Editor.Helpers
/// </summary>
public static class CodexConfigHelper
{
private static bool GetDevModeForceRefresh()
{
try
{
return EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false);
}
catch
{
return false;
}
}
private static void AddDevModeArgs(TomlArray args, bool devForceRefresh)
private static void AddDevModeArgs(TomlArray args)
{
if (args == null) return;
if (!devForceRefresh) return;
// Use central helper that checks both DevModeForceServerRefresh AND local path detection.
if (!AssetPathUtility.ShouldForceUvxRefresh()) return;
args.Add(new TomlString { Value = "--no-cache" });
args.Add(new TomlString { Value = "--refresh" });
}
@ -59,12 +48,11 @@ namespace MCPForUnity.Editor.Helpers
{
// Stdio mode: Use command and args
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = GetDevModeForceRefresh();
unityMCP["command"] = uvxPath;
var args = new TomlArray();
AddDevModeArgs(args, devForceRefresh);
AddDevModeArgs(args);
if (!string.IsNullOrEmpty(fromUrl))
{
args.Add(new TomlString { Value = "--from" });
@ -209,12 +197,11 @@ namespace MCPForUnity.Editor.Helpers
{
// Stdio mode: Use command and args
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = GetDevModeForceRefresh();
unityMCP["command"] = new TomlString { Value = uvxPath };
var argsArray = new TomlArray();
AddDevModeArgs(argsArray, devForceRefresh);
AddDevModeArgs(argsArray);
if (!string.IsNullOrEmpty(fromUrl))
{
argsArray.Add(new TomlString { Value = "--from" });

View File

@ -51,7 +51,9 @@ namespace MCPForUnity.Editor.Helpers
private static void PopulateUnityNode(JObject unity, string uvPath, McpClient client, bool isVSCode)
{
// Get transport preference (default to HTTP)
bool useHttpTransport = client?.SupportsHttpTransport != false && EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
bool prefValue = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
bool clientSupportsHttp = client?.SupportsHttpTransport != false;
bool useHttpTransport = clientSupportsHttp && prefValue;
string httpProperty = string.IsNullOrEmpty(client?.HttpUrlProperty) ? "url" : client.HttpUrlProperty;
var urlPropsToRemove = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "url", "serverUrl" };
urlPropsToRemove.Remove(httpProperty);
@ -81,10 +83,7 @@ namespace MCPForUnity.Editor.Helpers
// Stdio mode: Use uvx command
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = false;
try { devForceRefresh = EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); } catch { }
var toolArgs = BuildUvxArgs(fromUrl, packageName, devForceRefresh);
var toolArgs = BuildUvxArgs(fromUrl, packageName);
if (ShouldUseWindowsCmdShim(client))
{
@ -152,13 +151,15 @@ namespace MCPForUnity.Editor.Helpers
return created;
}
private static IList<string> BuildUvxArgs(string fromUrl, string packageName, bool devForceRefresh)
private static IList<string> BuildUvxArgs(string fromUrl, string packageName)
{
// Dev mode: force a fresh install/resolution (avoids stale cached builds while iterating).
// `--no-cache` is the key flag; `--refresh` ensures metadata is revalidated.
// Keep ordering consistent with other uvx builders: dev flags first, then --from <url>, then package name.
var args = new List<string>();
if (devForceRefresh)
// Use central helper that checks both DevModeForceServerRefresh AND local path detection.
if (AssetPathUtility.ShouldForceUvxRefresh())
{
args.Add("--no-cache");
args.Add("--refresh");

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MCPForUnity.Editor.Clients;
using MCPForUnity.Editor.Helpers;
using MCPForUnity.Editor.Models;
namespace MCPForUnity.Editor.Services
@ -22,11 +23,24 @@ namespace MCPForUnity.Editor.Services
public void ConfigureClient(IMcpClientConfigurator configurator)
{
// When using a local server path, clean stale build artifacts first.
// This prevents old deleted .py files from being picked up by Python's auto-discovery.
if (AssetPathUtility.IsLocalServerPath())
{
AssetPathUtility.CleanLocalServerBuildArtifacts();
}
configurator.Configure();
}
public ClientConfigurationSummary ConfigureAllDetectedClients()
{
// When using a local server path, clean stale build artifacts once before configuring all clients.
if (AssetPathUtility.IsLocalServerPath())
{
AssetPathUtility.CleanLocalServerBuildArtifacts();
}
var summary = new ClientConfigurationSummary();
foreach (var configurator in configurators)
{

View File

@ -406,6 +406,9 @@ namespace MCPForUnity.Editor.Services
/// </summary>
public bool StartLocalHttpServer()
{
/// Clean stale Python build artifacts when using a local dev server path
AssetPathUtility.CleanLocalServerBuildArtifacts();
if (!TryGetLocalHttpServerCommandParts(out _, out _, out var displayCommand, out var error))
{
EditorUtility.DisplayDialog(
@ -1236,10 +1239,8 @@ namespace MCPForUnity.Editor.Services
return false;
}
bool devForceRefresh = false;
try { devForceRefresh = EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); } catch { }
string devFlags = devForceRefresh ? "--no-cache --refresh " : string.Empty;
// Use central helper that checks both DevModeForceServerRefresh AND local path detection.
string devFlags = AssetPathUtility.ShouldForceUvxRefresh() ? "--no-cache --refresh " : string.Empty;
string args = string.IsNullOrEmpty(fromUrl)
? $"{devFlags}{packageName} --transport http --http-url {httpUrl}"
: $"{devFlags}--from {fromUrl} {packageName} --transport http --http-url {httpUrl}";

View File

@ -27,8 +27,9 @@ namespace MCPForUnity.Editor.Services
bool useHttp = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
// Check both TransportManager AND StdioBridgeHost directly, because CI starts via StdioBridgeHost
// bypassing TransportManager state.
bool isRunning = MCPServiceLocator.TransportManager.IsRunning(TransportMode.Stdio)
|| StdioBridgeHost.IsRunning;
bool tmRunning = MCPServiceLocator.TransportManager.IsRunning(TransportMode.Stdio);
bool hostRunning = StdioBridgeHost.IsRunning;
bool isRunning = tmRunning || hostRunning;
bool shouldResume = !useHttp && isRunning;
if (shouldResume)
@ -60,10 +61,12 @@ namespace MCPForUnity.Editor.Services
bool resume = false;
try
{
resume = EditorPrefs.GetBool(EditorPrefKeys.ResumeStdioAfterReload, false);
bool resumeFlag = EditorPrefs.GetBool(EditorPrefKeys.ResumeStdioAfterReload, false);
bool useHttp = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
resume = resume && !useHttp;
if (resume)
resume = resumeFlag && !useHttp;
// If we're not going to resume, clear the flag immediately to avoid stuck "Resuming..." state
if (!resume)
{
EditorPrefs.DeleteKey(EditorPrefKeys.ResumeStdioAfterReload);
}
@ -87,6 +90,13 @@ namespace MCPForUnity.Editor.Services
var startTask = MCPServiceLocator.TransportManager.StartAsync(TransportMode.Stdio);
startTask.ContinueWith(t =>
{
// Clear the flag after attempting to start (success or failure).
// This prevents getting stuck in "Resuming..." state.
// We do this synchronously on the continuation thread - it's safe because
// EditorPrefs operations are thread-safe and any new reload will set the flag
// fresh in OnBeforeAssemblyReload before we get here.
try { EditorPrefs.DeleteKey(EditorPrefKeys.ResumeStdioAfterReload); } catch { }
if (t.IsFaulted)
{
var baseEx = t.Exception?.GetBaseException();

View File

@ -84,6 +84,11 @@ namespace MCPForUnity.Editor.Windows.Components.ClientConfig
}
claudeCliPathRow.style.display = DisplayStyle.None;
// Initialize the configuration display for the first selected client
UpdateClientStatus();
UpdateManualConfiguration();
UpdateClaudeCliPathVisibility();
}
private void RegisterCallbacks()

View File

@ -156,6 +156,10 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
bool useHttp = selected != TransportProtocol.Stdio;
EditorPrefs.SetBool(EditorPrefKeys.UseHttpTransport, useHttp);
// Clear any stale resume flags when user manually changes transport
try { EditorPrefs.DeleteKey(EditorPrefKeys.ResumeStdioAfterReload); } catch { }
try { EditorPrefs.DeleteKey(EditorPrefKeys.ResumeHttpAfterReload); } catch { }
if (useHttp)
{
string scope = selected == TransportProtocol.HTTPRemote ? "remote" : "local";
@ -274,7 +278,9 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
bool isRunning = bridgeService.IsRunning;
bool showLocalServerControls = IsHttpLocalSelected();
bool debugMode = EditorPrefs.GetBool(EditorPrefKeys.DebugLogs, false);
bool stdioSelected = transportDropdown != null && (TransportProtocol)transportDropdown.value == TransportProtocol.Stdio;
// Use EditorPrefs as source of truth for stdio selection - more reliable after domain reload
// than checking the dropdown which may not be initialized yet
bool stdioSelected = !EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
// Keep the Start/Stop Server button label in sync even when the session is not running
// (e.g., orphaned server after a domain reload).
@ -327,6 +333,7 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
statusIndicator.RemoveFromClassList("disconnected");
statusIndicator.AddToClassList("connected");
connectionToggleButton.text = "End Session";
connectionToggleButton.SetEnabled(true); // Re-enable in case it was disabled during resumption
// Force the UI to reflect the actual port being used
unityPortField.value = bridgeService.CurrentPort.ToString();
@ -334,12 +341,30 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
}
else
{
connectionStatusLabel.text = "No Session";
statusIndicator.RemoveFromClassList("connected");
statusIndicator.AddToClassList("disconnected");
connectionToggleButton.text = "Start Session";
// Check if we're resuming the stdio bridge after a domain reload.
// During this brief window, show "Resuming..." instead of "No Session" to avoid UI flicker.
bool isStdioResuming = stdioSelected
&& EditorPrefs.GetBool(EditorPrefKeys.ResumeStdioAfterReload, false);
unityPortField.SetEnabled(true);
if (isStdioResuming)
{
connectionStatusLabel.text = "Resuming...";
// Keep the indicator in a neutral/transitional state
statusIndicator.RemoveFromClassList("connected");
statusIndicator.RemoveFromClassList("disconnected");
connectionToggleButton.text = "Start Session";
connectionToggleButton.SetEnabled(false);
}
else
{
connectionStatusLabel.text = "No Session";
statusIndicator.RemoveFromClassList("connected");
statusIndicator.AddToClassList("disconnected");
connectionToggleButton.text = "Start Session";
connectionToggleButton.SetEnabled(true);
}
unityPortField.SetEnabled(!isStdioResuming);
healthStatusLabel.text = HealthStatusUnknown;
healthIndicator.RemoveFromClassList("healthy");

View File

@ -39,6 +39,7 @@ namespace MCPForUnity.Editor.Windows
{ EditorPrefKeys.SetupDismissed, EditorPrefType.Bool },
{ EditorPrefKeys.CustomToolRegistrationEnabled, EditorPrefType.Bool },
{ EditorPrefKeys.TelemetryDisabled, EditorPrefType.Bool },
{ EditorPrefKeys.DevModeForceServerRefresh, EditorPrefType.Bool },
// Integer prefs
{ EditorPrefKeys.UnitySocketPort, EditorPrefType.Int },

View File

@ -21,9 +21,21 @@ namespace MCPForUnityTests.Editor.Helpers
private string _fakeUvPath;
private string _serverSrcDir;
// Save/restore original pref values (must happen BEFORE Assert.Ignore since TearDown still runs)
private bool _hadHttpTransport;
private bool _originalHttpTransport;
private bool _hadHttpUrl;
private string _originalHttpUrl;
[SetUp]
public void SetUp()
{
// Save original pref values FIRST - TearDown runs even when test is ignored!
_hadHttpTransport = EditorPrefs.HasKey(UseHttpTransportPrefKey);
_originalHttpTransport = EditorPrefs.GetBool(UseHttpTransportPrefKey, true);
_hadHttpUrl = EditorPrefs.HasKey(HttpUrlPrefKey);
_originalHttpUrl = EditorPrefs.GetString(HttpUrlPrefKey, "");
// Tests are designed for Linux/macOS runners. Skip on Windows due to ProcessStartInfo
// restrictions when UseShellExecute=false for .cmd/.bat scripts.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -62,8 +74,17 @@ namespace MCPForUnityTests.Editor.Helpers
EditorPrefs.DeleteKey(EditorPrefKeys.ServerSrc);
EditorPrefs.DeleteKey(EditorPrefKeys.LockCursorConfig);
EditorPrefs.DeleteKey(EditorPrefKeys.AutoRegisterEnabled);
EditorPrefs.DeleteKey(UseHttpTransportPrefKey);
EditorPrefs.DeleteKey(HttpUrlPrefKey);
// Restore original pref values (don't delete if user had them set!)
if (_hadHttpTransport)
EditorPrefs.SetBool(UseHttpTransportPrefKey, _originalHttpTransport);
else
EditorPrefs.DeleteKey(UseHttpTransportPrefKey);
if (_hadHttpUrl)
EditorPrefs.SetString(HttpUrlPrefKey, _originalHttpUrl);
else
EditorPrefs.DeleteKey(HttpUrlPrefKey);
// Remove temp files
try { if (Directory.Exists(_tempRoot)) Directory.Delete(_tempRoot, true); } catch { }