示例#1
0
        internal void UpdatePackageInfo(PackageInfo newPackageInfo)
        {
            m_IsFullyFetched = m_Version == newPackageInfo.version;
            m_PackageInfo    = newPackageInfo;
            m_Source         = m_PackageInfo.source == PackageSource.BuiltIn || m_IsInstalled ? m_PackageInfo.source : PackageSource.Registry;

            RefreshTags();

            m_Author = string.IsNullOrEmpty(m_PackageInfo.author.name) &&
                       m_PackageInfo.name.StartsWith(k_UnityPrefix) ? "Unity Technologies Inc." : m_PackageInfo.author.name;

            if (m_Source == PackageSource.BuiltIn)
            {
                m_Description = UpmPackageDocs.SplitBuiltinDescription(this)[0];
            }

            // reset sample parse status on package info update, such that the sample list gets regenerated
            m_SamplesParsed = false;

            if (m_IsFullyFetched)
            {
                m_DisplayName = GetDisplayName(m_PackageInfo);
                m_PackageId   = m_PackageInfo.packageId;
                if (hasPathInId)
                {
                    m_PackageId = m_PackageId.Replace("\\", "/");
                }
            }
            else
            {
                m_PackageId = FormatPackageId(name, version.ToString());
            }
        }
示例#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 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" }
                    });
                }
            }
        }
示例#3
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" }
                    });
                }
            }
        }
示例#4
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);
        }
示例#5
0
        internal void UpdatePackageInfo(PackageInfo newPackageInfo)
        {
            m_IsFullyFetched  = m_Version == newPackageInfo.version;
            m_PackageInfo     = newPackageInfo;
            m_PackageUniqueId = m_PackageInfo.name;

            RefreshTags();

            // For core packages, or packages that are bundled with Unity without being published, use Unity's build date
            m_PublishedDateTicks = 0;
            if (HasTag(PackageTag.Bundled) && m_PackageInfo.datePublished == null)
            {
                m_PublishedDateTicks = new DateTime(1970, 1, 1).Ticks + InternalEditorUtility.GetUnityVersionDate() * TimeSpan.TicksPerSecond;
            }

            m_Author = string.IsNullOrEmpty(m_PackageInfo.author.name) &&
                       m_PackageInfo.name.StartsWith(k_UnityPrefix) ? "Unity Technologies Inc." : m_PackageInfo.author.name;

            if (HasTag(PackageTag.BuiltIn))
            {
                m_Description = UpmPackageDocs.SplitBuiltinDescription(this)[0];
            }

            // reset sample parse status on package info update, such that the sample list gets regenerated
            m_SamplesParsed = false;

            if (m_IsFullyFetched)
            {
                m_DisplayName = GetDisplayName(m_PackageInfo);
                m_PackageId   = m_PackageInfo.packageId;
                if (installedFromPath)
                {
                    m_PackageId = m_PackageId.Replace("\\", "/");
                }
            }
            else
            {
                m_PackageId = FormatPackageId(name, version.ToString());
            }
        }
示例#6
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();
        }