diff --git a/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs b/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs index 7f22c41..9d5682f 100644 --- a/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs +++ b/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs @@ -33,15 +33,7 @@ namespace UnityMcpBridge.Editor.Helpers } else { - string pyprojectPath = Path.Combine( - saveLocation, - ServerFolder, - "src", - "pyproject.toml" - ); - string installedVersion = ParseVersionFromPyproject( - File.ReadAllText(pyprojectPath) - ); + string installedVersion = GetInstalledVersion(); string latestVersion = GetLatestVersion(); if (IsNewerVersion(latestVersion, installedVersion)) @@ -148,10 +140,24 @@ namespace UnityMcpBridge.Editor.Helpers RunCommand("git", $"checkout {BranchName}", workingDirectory: location); } + /// + /// Fetches the currently installed version from the local pyproject.toml file. + /// + public static string GetInstalledVersion() + { + string pyprojectPath = Path.Combine( + GetSaveLocation(), + ServerFolder, + "src", + "pyproject.toml" + ); + return ParseVersionFromPyproject(File.ReadAllText(pyprojectPath)); + } + /// /// Fetches the latest version from the GitHub pyproject.toml file. /// - private static string GetLatestVersion() + public static string GetLatestVersion() { using WebClient webClient = new(); string pyprojectContent = webClient.DownloadString(PyprojectUrl); @@ -188,7 +194,7 @@ namespace UnityMcpBridge.Editor.Helpers /// /// Compares two version strings to determine if the latest is newer. /// - private static bool IsNewerVersion(string latest, string installed) + public static bool IsNewerVersion(string latest, string installed) { int[] latestParts = latest.Split('.').Select(int.Parse).ToArray(); int[] installedParts = installed.Split('.').Select(int.Parse).ToArray();