Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        private void OnEnable()
        {
            _windowInstance = this;

            _installedVersion = MyBoxUtilities.GetMyBoxInstalledVersion();
            MyBoxUtilities.GetMyBoxLatestVersionAsync(version =>
            {
                _latestVersion = version;
                if (_windowInstance != null)
                {
                    _windowInstance.Repaint();
                }
            });
        }
Beispiel #4
0
 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);
         }
     });
 }
Beispiel #5
0
 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);
             }
         });
     }
 }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 public bool VersionsMatch(MyBoxVersion version)
 {
     return(BaseVersionMatch(version) && Patch == version.Patch);
 }
Beispiel #8
0
 /// <summary>
 /// Major & Minor versions match, skip patch releases
 /// </summary>
 public bool BaseVersionMatch(MyBoxVersion version)
 {
     return(Major == version.Major && Minor == version.Minor);
 }