Esempio n. 1
0
        public UpdateWindow()
        {
            this.titleContent = new GUIContent(Resources.UI_UNITYPLUGIN_WINDOW_UPDATE_TITLE);
            this.minSize      = new Vector2(380, 290);
            this.position     = new Rect(
                (Screen.width - this.minSize.x) / 2,
                (Screen.height - this.minSize.y) / 2,
                this.minSize.x,
                this.minSize.y
                );
            this.padding = new Rect(10, 10, 10, 10);

            this.rows = Array.ConvertAll(ProductInformation.GetKnownProducts(), p => new ProductRow(p.Id, p.Name, p.Disabled)
            {
                CurrentVersion  = p.CurrentVersion,
                AllBuilds       = p.AllBuilds,
                Location        = p.Location,
                ExpectedVersion = p.ExpectedVersion
            });

            this.columns = new[] {
                new ProductColumn(Resources.UI_UNITYPLUGIN_WINDOW_UPDATE_PRODUCT_COLUMN_NAME, RenderProductCell)
                {
                    Flex = true, Width = 10
                },
                new ProductColumn(Resources.UI_UNITYPLUGIN_WINDOW_UPDATE_CURRENT_VERSION_COLUMN_NAME, RenderCurrentVersionCell)
                {
                    Width = 100
                },
                new ProductColumn(Resources.UI_UNITYPLUGIN_WINDOW_UPDATE_AVAILABLE_VERSION_COLUMN_NAME, RenderSelectedVersionCell)
                {
                    Width = 100
                },
                new ProductColumn(Resources.UI_UNITYPLUGIN_WINDOW_UPDATE_ACTION_COLUMN_NAME, RenderActionCell)
                {
                    Width = 80
                }
            };

            this.UpdateColumnWidths();

            for (var i = 0; i < this.rows.Length; i++)
            {
                var row = this.rows[i];
                if (row.CurrentVersion.IsCompleted == false)
                {
                    row.CurrentVersion.ContinueWith(this.ContinueWithRepaint);
                }
                if (row.AllBuilds.IsCompleted == false)
                {
                    row.AllBuilds.ContinueWith(this.ContinueWithRepaint);
                }

                Promise.WhenAll(row.CurrentVersion, row.AllBuilds)
                .ContinueWith(p => ChooseAction(row))
                .ContinueWith(this.ContinueWithRepaint);
            }
        }
Esempio n. 2
0
        private static IEnumerable CheckForUpdates()
        {
            if (Settings.Current.Verbose)
            {
                Debug.Log("Checking for product updates.");
            }

            var products = ProductInformation.GetKnownProducts();

            yield return(Promise.WhenAll(products.Select(p => p.AllBuilds).ToArray()));

            yield return(Promise.WhenAll(products.Select(p => p.CurrentVersion).ToArray()));

            var releaseNotes = new StringBuilder();

            foreach (var product in products)
            {
                if (product.CurrentVersion.HasErrors || product.AllBuilds.HasErrors)
                {
                    continue;                     // has errors
                }

                var currentVersion = (product.ExpectedVersion ?? product.CurrentVersion.GetResult());
                var lastVersion    = product.AllBuilds.GetResult().Select(p => p.Version).Max();
                if (lastVersion <= currentVersion)
                {
                    continue;                     // no updates
                }

                releaseNotes.AppendFormat("<size=20>{0}</size>" + Environment.NewLine, product.Name);
                releaseNotes.AppendLine();

                var getReleaseNotesAsync = PackageManager.GetReleaseNotes(product.Id, currentVersion, lastVersion);
                yield return(getReleaseNotesAsync);

                if (getReleaseNotesAsync.HasErrors)
                {
                    continue;                     // has errors
                }

                releaseNotes.AppendLine(getReleaseNotesAsync.GetResult());
                releaseNotes.AppendLine();
            }

            var window = EditorWindow.GetWindow <UpdateAvailableWindow>(utility: true);

            window.ReleaseNotes = releaseNotes.ToString();

            SaveLastCheckTime(LastCheckTime = DateTime.UtcNow);
            CheckCooldownTime = DateTime.UtcNow + UpdateCheckCooldown;
        }