Example #1
0
        private void RefreshLinks()
        {
            var isBuiltIn           = displayVersion.HasTag(PackageTag.BuiltIn);
            var isAssetStorePackage = displayVersion.HasTag(PackageTag.AssetStore);

            detailLinks.Clear();
            if (!isAssetStorePackage)
            {
                UIUtils.SetElementDisplay(detailLinksContainer, true);
                detailLinks.Add(new Button(ViewDocClick)
                {
                    text = "View documentation", classList = { "unity-button", "link" }
                });

                if (UpmPackageDocs.HasChangelog(displayVersion))
                {
                    detailLinks.Add(new Button(ViewChangelogClick)
                    {
                        text = "View changelog", classList = { "unity-button", "link" }
                    });
                }

                if (!isBuiltIn)
                {
                    detailLinks.Add(new Button(ViewLicensesClick)
                    {
                        text = "View licenses", classList = { "unity-button", "link" }
                    });
                }
            }
            else
            {
                UIUtils.SetElementDisplay(detailLinksContainer, displayVersion.links.Any());
                foreach (var link in displayVersion.links)
                {
                    var tooltip = link.url;
                    var url     = link.url;
                    if (!url.StartsWith("http:", StringComparison.InvariantCulture) && !url.StartsWith("https:", StringComparison.InvariantCulture))
                    {
                        url     = AssetStoreUtils.instance.assetStoreUrl + url;
                        tooltip = string.Empty;
                    }
                    detailLinks.Add(new Button(() => { ApplicationUtil.instance.OpenURL(url); })
                    {
                        text      = link.name,
                        tooltip   = tooltip,
                        classList = { "unity-button", "link" }
                    });
                }
            }
        }
Example #2
0
        private void RefreshLinks()
        {
            var isBuiltIn           = displayVersion.HasTag(PackageTag.BuiltIn);
            var isAssetStorePackage = displayVersion.HasTag(PackageTag.AssetStore);

            detailLinks.Clear();
            if (!isAssetStorePackage)
            {
                UIUtils.SetElementDisplay(detailLinksContainer, true);
                detailLinks.Add(new Button(ViewDocClick)
                {
                    text = "View documentation", classList = { "unity-button", "link" }
                });

                if (UpmPackageDocs.HasChangelog(displayVersion))
                {
                    detailLinks.Add(new Button(ViewChangelogClick)
                    {
                        text = "View changelog", classList = { "unity-button", "link" }
                    });
                }

                if (!isBuiltIn)
                {
                    detailLinks.Add(new Button(ViewLicensesClick)
                    {
                        text = "View licenses", classList = { "unity-button", "link" }
                    });
                }
            }
            else
            {
                UIUtils.SetElementDisplay(detailLinksContainer, displayVersion.links.Any());
                foreach (var link in displayVersion.links)
                {
                    var url = $"{AssetStoreUtils.instance.assetStoreUrl}{link.url}";
                    detailLinks.Add(new Button(() => { ApplicationUtil.instance.OpenURL(url); })
                    {
                        text = link.name, classList = { "unity-button", "link" }
                    });
                }
            }
        }
Example #3
0
        private void RefreshLinks()
        {
            detailLinks.Clear();
            // add links from the package
            foreach (var link in package.links)
            {
                detailLinks.Add(new Button(() => { ApplicationUtil.instance.OpenURL(link.url); })
                {
                    text      = link.name,
                    tooltip   = link.url,
                    classList = { "unity-button", "link" }
                });
            }

            // add links related to the upm version
            if (UpmPackageDocs.HasDocs(displayVersion))
            {
                detailLinks.Add(new Button(ViewDocClick)
                {
                    text = ApplicationUtil.instance.GetTranslationForText("View documentation"), classList = { "unity-button", "link" }
                });
            }

            if (UpmPackageDocs.HasChangelog(displayVersion))
            {
                detailLinks.Add(new Button(ViewChangelogClick)
                {
                    text = ApplicationUtil.instance.GetTranslationForText("View changelog"), classList = { "unity-button", "link" }
                });
            }

            if (UpmPackageDocs.HasLicenses(displayVersion))
            {
                detailLinks.Add(new Button(ViewLicensesClick)
                {
                    text = ApplicationUtil.instance.GetTranslationForText("View licenses"), classList = { "unity-button", "link" }
                });
            }

            UIUtils.SetElementDisplay(detailLinksContainer, detailLinks.childCount != 0);
        }
Example #4
0
        private void SetDisplayVersion(IPackageVersion version)
        {
            displayVersion = version;

            var detailVisible = package != null && displayVersion != null;

            if (!detailVisible)
            {
                RefreshExtensions(null);
            }
            else
            {
                SetUpdateVisibility(true);
                var isBuiltIn = displayVersion.HasTag(PackageTag.BuiltIn);
                UIUtils.SetElementDisplay(viewDocButton, true);
                UIUtils.SetElementDisplay(viewLicensesContainer, !isBuiltIn);
                removeButton.visible = true;

                var hasDescription = !string.IsNullOrEmpty(displayVersion.description);
                detailDesc.text = hasDescription ? displayVersion.description : "There is no description for this package.";
                detailDesc.EnableClass(k_EmptyDescriptionClass, !hasDescription);

                detailTitle.text   = displayVersion.displayName;
                detailVersion.text = "Version " + displayVersion.version.StripTag();

                foreach (var tag in k_VisibleTags)
                {
                    UIUtils.SetElementDisplay(GetTagLabel(tag), displayVersion.HasTag(tag));
                }

                UIUtils.SetElementDisplay(editPackageManifestButton, displayVersion.isInstalled && !displayVersion.HasTag(PackageTag.BuiltIn));
                UIUtils.SetElementDisplay(documentationContainer, true);
                UIUtils.SetElementDisplay(changelogContainer, UpmPackageDocs.HasChangelog(displayVersion));

                sampleList.SetPackage(displayVersion);

                detailName.text = displayVersion.name;
                detailScrollView.scrollOffset = new Vector2(0, 0);

                detailAuthor.text = "";
                if (!string.IsNullOrEmpty(displayVersion.author))
                {
                    detailAuthor.text = $"Author: {displayVersion.author}";
                }

                // If the package details is not enabled, don't update the date yet as we are fetching new information
                if (enabledSelf)
                {
                    detailDate.text = "";

                    // In Development packages are not published, so we do not show any published date
                    if (displayVersion != null && !displayVersion.HasTag(PackageTag.InDevelopment))
                    {
                        if (displayVersion.datePublished != null)
                        {
                            detailDate.text = $"Published Date: {displayVersion.datePublished.Value:MMMM dd,  yyyy}";
                        }
                        else if (displayVersion.HasTag(PackageTag.Core) || displayVersion.isInstalled)
                        {
                            // For core packages, or installed packages that are bundled with Unity without being published, use Unity's build date
                            var unityBuildDate = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                            unityBuildDate  = unityBuildDate.AddSeconds(InternalEditorUtility.GetUnityVersionDate());
                            detailDate.text = $"Published Date: {unityBuildDate:MMMM dd, yyyy}";
                        }
                    }
                }

                UIUtils.SetElementDisplay(detailVersion, !isBuiltIn);
                UIUtils.SetElementDisplayNonEmpty(detailAuthor);
                UIUtils.SetElementDisplayNonEmpty(detailDate);

                RefreshPackageActionButtons();

                UIUtils.SetElementDisplay(customContainer, true);

                RefreshExtensions(displayVersion);

                SetDependenciesVisibility(PackageManagerPrefs.instance.showPackageDependencies);
            }
            OnEditorSelectionChanged();

            // Set visibility
            SetContentVisibility(detailVisible);
            RefreshErrorDisplay();
        }