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
26 changes: 26 additions & 0 deletions UnityMcpBridge/Editor/Helpers/ServerInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -569,6 +570,31 @@ internal static string FindUvPath()
}
catch { }

// Windows Store (PythonSoftwareFoundation) install location probe
// Example: %LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.13_*\LocalCache\local-packages\Python313\Scripts\uv.exe
try
{
string pkgsRoot = Path.Combine(localAppData, "Packages");
if (Directory.Exists(pkgsRoot))
{
var pythonPkgs = Directory.GetDirectories(pkgsRoot, "PythonSoftwareFoundation.Python.*", SearchOption.TopDirectoryOnly)
.OrderByDescending(p => p, StringComparer.OrdinalIgnoreCase);
foreach (var pkg in pythonPkgs)
{
string localCache = Path.Combine(pkg, "LocalCache", "local-packages");
if (!Directory.Exists(localCache)) continue;
var pyRoots = Directory.GetDirectories(localCache, "Python*", SearchOption.TopDirectoryOnly)
.OrderByDescending(d => d, StringComparer.OrdinalIgnoreCase);
foreach (var pyRoot in pyRoots)
{
string uvExe = Path.Combine(pyRoot, "Scripts", "uv.exe");
if (File.Exists(uvExe) && ValidateUvBinary(uvExe)) return uvExe;
}
}
}
}
catch { }

candidates = new[]
{
// Preferred: WinGet Links shims (stable entrypoints)
Expand Down
26 changes: 23 additions & 3 deletions UnityMcpBridge/Editor/Tools/ManageScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,8 @@ public static void Schedule(string relPath, TimeSpan window)
// Kick off a ticking callback that waits until the window has elapsed
// from the last request before performing the refresh.
EditorApplication.delayCall += () => Tick(window);
// Nudge the editor loop so ticks run even if the window is unfocused
EditorApplication.QueuePlayerLoopUpdate();
}

private static void Tick(TimeSpan window)
Expand Down Expand Up @@ -2595,7 +2597,10 @@ private static void Tick(TimeSpan window)
string[] toImport;
lock (_lock) { toImport = _paths.ToArray(); _paths.Clear(); }
foreach (var p in toImport)
AssetDatabase.ImportAsset(p, ImportAssetOptions.ForceUpdate);
{
var sp = ManageScriptRefreshHelpers.SanitizeAssetsPath(p);
AssetDatabase.ImportAsset(sp, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
}
#if UNITY_EDITOR
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
#endif
Expand All @@ -2607,16 +2612,31 @@ private static void Tick(TimeSpan window)

static class ManageScriptRefreshHelpers
{
public static string SanitizeAssetsPath(string p)
{
if (string.IsNullOrEmpty(p)) return p;
p = p.Replace('\\', '/').Trim();
if (p.StartsWith("unity://path/", StringComparison.OrdinalIgnoreCase))
p = p.Substring("unity://path/".Length);
while (p.StartsWith("Assets/Assets/", StringComparison.OrdinalIgnoreCase))
p = p.Substring("Assets/".Length);
if (!p.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase))
p = "Assets/" + p.TrimStart('/');
return p;
}

public static void ScheduleScriptRefresh(string relPath)
{
RefreshDebounce.Schedule(relPath, TimeSpan.FromMilliseconds(200));
var sp = SanitizeAssetsPath(relPath);
RefreshDebounce.Schedule(sp, TimeSpan.FromMilliseconds(200));
}

public static void ImportAndRequestCompile(string relPath, bool synchronous = true)
{
var sp = SanitizeAssetsPath(relPath);
var opts = ImportAssetOptions.ForceUpdate;
if (synchronous) opts |= ImportAssetOptions.ForceSynchronousImport;
AssetDatabase.ImportAsset(relPath, opts);
AssetDatabase.ImportAsset(sp, opts);
#if UNITY_EDITOR
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
#endif
Expand Down
2 changes: 1 addition & 1 deletion UnityMcpBridge/UnityMcpServer~/src/server_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.2.0