public static async void GetMyBoxLatestVersionAsync(Action <MyBoxVersion> onVersionRetrieved) { try { using (HttpClient client = new HttpClient()) { var packageJson = await client.GetStringAsync(MyBoxPackageInfoURL); var versionRaw = RetrievePackageVersionOutOfJson(packageJson); if (versionRaw == null) { Debug.LogWarning("MyBox was unable to parse package.json :("); return; } var version = new MyBoxVersion(versionRaw); if (onVersionRetrieved != null) { onVersionRetrieved(version); } } } catch (HttpRequestException) { //TODO: It's probably some internet connection issue at this point. Should I notify user about it? //Debug.LogWarning("MyBox is unable to check version online :(. Exception is: " + requestException.Message); } }
public static async void GetMyBoxLatestVersionAsync(Action <MyBoxVersion> onVersionRetrieved) { try { using (HttpClient client = new HttpClient()) { var packageJson = await client.GetStringAsync(MyBoxPackageInfoURL); var versionRaw = RetrievePackageVersionOutOfJson(packageJson); if (versionRaw == null) { Debug.LogWarning("MyBox was unable to parse package.json :("); return; } var version = new MyBoxVersion(versionRaw); if (onVersionRetrieved != null) { onVersionRetrieved(version); } } } catch (HttpRequestException requestException) { Debug.LogWarning("MyBox is unable to check version online :(. Exception is: " + requestException.Message); } }
private void OnEnable() { _windowInstance = this; _installedVersion = MyBoxUtilities.GetMyBoxInstalledVersion(); MyBoxUtilities.GetMyBoxLatestVersionAsync(version => { _latestVersion = version; if (_windowInstance != null) { _windowInstance.Repaint(); } }); }
private static void CheckForUpdates() { MyEditorEvents.OnEditorStarts -= CheckForUpdates; MyBoxUtilities.GetMyBoxLatestVersionAsync(version => { _installedVersion = MyBoxUtilities.GetMyBoxInstalledVersion(); _latestVersion = version; if (!_installedVersion.VersionsMatch(_latestVersion)) { var versions = "Installed version: " + _installedVersion.AsSting + ". Latest version: " + _latestVersion.AsSting; var message = "It's time to update MyBox :)! Use \"Tools/MyBox/Update MyBox\". " + versions; WarningsPool.Log(message); } }); }
static MyBoxWindow() { if (AutoUpdateCheckIsEnabled) { MyBoxUtilities.GetMyBoxLatestVersionAsync(version => { _installedVersion = MyBoxUtilities.GetMyBoxInstalledVersion(); _latestVersion = version; if (!_installedVersion.VersionsMatch(_latestVersion)) { var versions = "Installed version: " + _installedVersion.AsSting + ". Latest version: " + _latestVersion.AsSting; Debug.Log("It's time to update MyBox :)! Use \"Tools/MyBox/Update MyBox\". " + versions); } }); } }
public static MyBoxVersion GetMyBoxInstalledVersion() { var packageJsonPath = PackageJsonPath; if (packageJsonPath == null) { Debug.LogWarning("MyBox is unable to check installed version :("); return(null); } var packageJsonContents = File.ReadAllText(packageJsonPath); var versionRaw = RetrievePackageVersionOutOfJson(packageJsonContents); if (versionRaw == null) { Debug.LogWarning("MyBox was unable to parse package.json :("); return(null); } var version = new MyBoxVersion(versionRaw); return(version); }
public bool VersionsMatch(MyBoxVersion version) { return(BaseVersionMatch(version) && Patch == version.Patch); }
/// <summary> /// Major & Minor versions match, skip patch releases /// </summary> public bool BaseVersionMatch(MyBoxVersion version) { return(Major == version.Major && Minor == version.Minor); }