private void RefreshChangeLog()
        {
            UIUtils.SetElementDisplay(versionHistoryItemChangeLogContainer, false);
            UIUtils.SetElementDisplay(versionHistoryItemChangeLogTitle, false);
            UIUtils.SetElementDisplay(versionHistoryItemChangeLogLabel, false);
            UIUtils.SetElementDisplay(versionHistoryItemChangeLogLink, false);

            var upmReserved        = m_UpmCache.ParseUpmReserved(m_Version?.packageInfo);
            var changeLog          = upmReserved?.GetString("changelog");
            var hasChangeLogInInfo = !string.IsNullOrEmpty(changeLog);

            if (hasChangeLogInInfo)
            {
                versionHistoryItemChangeLogLabel.text = changeLog;
                UIUtils.SetElementDisplay(versionHistoryItemChangeLogTitle, true);
                UIUtils.SetElementDisplay(versionHistoryItemChangeLogLabel, true);
                UIUtils.SetElementDisplay(versionHistoryItemChangeLogContainer, true);
            }

            if (UpmPackageDocs.HasChangelog(m_Version))
            {
                versionHistoryItemChangeLogLink.text = hasChangeLogInInfo ? L10n.Tr("See full changelog") : L10n.Tr("See changelog");
                UIUtils.SetElementDisplay(versionHistoryItemChangeLogLink, true);
                UIUtils.SetElementDisplay(versionHistoryItemChangeLogContainer, true);
            }
        }
        private void ViewUrl(string[] onlineUrls, string offlineDocPath, string docType, string analyticsEvent)
        {
            if (m_Application.isInternetReachable)
            {
                if (onlineUrls.Length == 0)
                {
                    UpmPackageDocs.HandleInvalidOrUnreachableOnlineUrl(string.Empty, offlineDocPath, docType, analyticsEvent, m_Version, m_Package, m_Application);
                    return;
                }

                UpmPackageDocs.OpenWebUrl(onlineUrls[0], m_Version, m_Application, analyticsEvent, () =>
                {
                    var urls = new List <string>(onlineUrls).Skip(1).ToArray();
                    ViewUrl(urls, offlineDocPath, docType, analyticsEvent);
                });
            }
            else
            {
                UpmPackageDocs.HandleInvalidOrUnreachableOnlineUrl(string.Empty, offlineDocPath, docType, analyticsEvent, m_Version, m_Package, m_Application);
            }
        }
Ejemplo n.º 3
0
        internal void UpdatePackageInfo(PackageInfo newPackageInfo, bool isUnityPackage)
        {
            m_IsFullyFetched  = m_Version?.ToString() == newPackageInfo.version;
            m_PackageInfo     = newPackageInfo;
            m_PackageUniqueId = m_PackageInfo.name;
            m_IsUnityPackage  = isUnityPackage;

            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 = this.isUnityPackage ? k_UnityAuthor : m_PackageInfo.author?.name ?? string.Empty;

            if (HasTag(PackageTag.BuiltIn))
            {
                m_Description = UpmPackageDocs.FetchBuiltinDescription(this);
            }

            if (m_IsFullyFetched)
            {
                m_DisplayName = GetDisplayName(m_PackageInfo);
                m_PackageId   = m_PackageInfo.packageId;
                if (installedFromPath)
                {
                    m_PackageId = m_PackageId.Replace("\\", "/");
                }

                ProcessSignatureErrors(newPackageInfo);
            }
            else
            {
                m_PackageId = FormatPackageId(name, version.ToString());
            }
        }
        public PackageDetailsVersionHistoryItem(ResourceLoader resourceLoader,
                                                PackageDatabase packageDatabase,
                                                UpmCache upmCache,
                                                ApplicationProxy applicationProxy,
                                                IOProxy ioProxy,
                                                IPackageVersion version,
                                                bool multipleVersionsVisible,
                                                bool isLatestVersion,
                                                bool expanded,
                                                PackageToolBarRegularButton button)
        {
            m_Version          = version;
            m_PackageDatabase  = packageDatabase;
            m_UpmCache         = upmCache;
            m_ApplicationProxy = applicationProxy;
            m_IOProxy          = ioProxy;

            var root = resourceLoader.GetTemplate("PackageDetailsVersionHistoryItem.uxml");

            Add(root);
            m_Cache = new VisualElementCache(root);

            SetExpanded(expanded);
            versionHistoryItemToggle.RegisterValueChangedCallback(evt =>
            {
                SetExpanded(evt.newValue);
                onToggleChanged?.Invoke(evt.newValue);
            });

            m_Button = button;
            if (m_Button != null)
            {
                versionHistoryItemToggleRightContainer.Add(m_Button.element);
            }

            versionHistoryItemChangeLogLink.clickable.clicked += () => UpmPackageDocs.ViewUrl(UpmPackageDocs.GetChangelogUrl(m_Version), UpmPackageDocs.GetOfflineChangelog(m_IOProxy, m_Version), L10n.Tr("changelog"), "viewChangelog", m_Version, m_Version.package, m_ApplicationProxy);

            Refresh(multipleVersionsVisible, isLatestVersion);
        }
Ejemplo n.º 5
0
 private void ViewQuickStartClick()
 {
     UpmPackageDocs.ViewUrl(UpmPackageDocs.GetQuickStartUrl(m_Version, m_UpmCache), string.Empty, L10n.Tr("quick start documentation"), "viewQuickstart", m_Version, m_Package, m_Application);
 }
Ejemplo n.º 6
0
        private void RefreshQuickStart()
        {
            var showQuickStartButton = m_Package.Is(PackageType.Feature) && !string.IsNullOrEmpty(UpmPackageDocs.GetQuickStartUrl(m_Version, m_UpmCache));

            if (showQuickStartButton)
            {
                quickStart.Clear();
                quickStart.Add(new VisualElement {
                    classList = { "quickStartIcon" }
                });
                quickStart.Add(new TextElement {
                    text = L10n.Tr("QuickStart"), classList = { "quickStartText" }
                });
            }
            UIUtils.SetElementDisplay(quickStart, showQuickStartButton);
        }
        public void Refresh(IPackage package, IPackageVersion version)
        {
            m_Package = package;
            m_Version = version;
            Clear();

            if (package == null || version == null)
            {
                return;
            }

            var leftItems = new VisualElement {
                classList = { "left" }
            };

            Add(leftItems);

            // add links from the package
            foreach (var link in package.links)
            {
                if (string.IsNullOrEmpty(link.name) || string.IsNullOrEmpty(link.url))
                {
                    continue;
                }
                AddToLinks(leftItems, new Button(() =>
                {
                    m_Application.OpenURL(link.url);
                    if (!string.IsNullOrEmpty(link.analyticsEventName))
                    {
                        PackageManagerWindowAnalytics.SendEvent(link.analyticsEventName, version?.uniqueId);
                    }
                })
                {
                    text      = link.name,
                    tooltip   = link.url,
                    classList = { k_LinkClass }
                }, package.links.First() != link);
            }

            // add links related to the upm version
            if (UpmPackageDocs.HasDocs(version))
            {
                AddToLinks(leftItems, new Button(ViewDocClick)
                {
                    text = k_ViewDocumentationText, classList = { k_LinkClass }
                }, false);
            }

            if (UpmPackageDocs.HasChangelog(version))
            {
                AddToLinks(leftItems, new Button(ViewChangelogClick)
                {
                    text = k_ViewChangelogText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasLicenses(version))
            {
                AddToLinks(leftItems, new Button(ViewLicensesClick)
                {
                    text = k_ViewLicensesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasUseCases(version))
            {
                AddToLinks(leftItems, new Button(ViewUseCasesClick)
                {
                    text = k_ViewUseCasesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasDashboard(version))
            {
                AddToLinks(leftItems, new Button(ViewDashboardClick)
                {
                    text = k_ViewDashboardText, classList = { k_LinkClass }
                });
            }

            UIUtils.SetElementDisplay(this, childCount != 0);
        }
 private void ViewDashboardClick()
 {
     UpmPackageDocs.ViewUrl(UpmPackageDocs.GetDashboardUrl(m_Version), UpmPackageDocs.GetOfflineDashboardUrl(m_IOProxy, m_Version), L10n.Tr("dashboard"), "viewDashboard", m_Version, m_Package, m_Application);
 }
 private void ViewUseCasesClick()
 {
     UpmPackageDocs.ViewUrl(UpmPackageDocs.GetUseCasesUrl(m_Version), UpmPackageDocs.GetOfflineUseCasesUrl(m_IOProxy, m_Version), L10n.Tr("use cases"), "viewUseCases", m_Version, m_Package, m_Application);
 }
 private void ViewLicensesClick()
 {
     UpmPackageDocs.ViewUrl(UpmPackageDocs.GetLicensesUrl(m_Version), UpmPackageDocs.GetOfflineLicenses(m_IOProxy, m_Version), L10n.Tr("license documentation"), "viewLicense", m_Version, m_Package, m_Application);
 }
 private void ViewChangelogClick()
 {
     UpmPackageDocs.ViewUrl(UpmPackageDocs.GetChangelogUrl(m_Version), UpmPackageDocs.GetOfflineChangelog(m_IOProxy, m_Version), L10n.Tr("changelog"), "viewChangelog", m_Version, m_Package, m_Application);
 }
 private void ViewDocClick()
 {
     ViewUrl(UpmPackageDocs.GetDocumentationUrl(m_Version), UpmPackageDocs.GetOfflineDocumentation(m_IOProxy, m_Version), L10n.Tr("documentation"), "viewDocs");
 }
Ejemplo n.º 13
0
        public void Refresh(IPackage package, IPackageVersion version)
        {
            m_Package = package;
            m_Version = version;
            Clear();

            if (package == null || version == null)
            {
                return;
            }

            var leftItems = new VisualElement {
                classList = { "left" }
            };

            Add(leftItems);

            // add links from the package
            foreach (var link in package.links)
            {
                if (string.IsNullOrEmpty(link.name) || string.IsNullOrEmpty(link.url))
                {
                    continue;
                }
                AddToLinks(leftItems, new Button(() => { m_Application.OpenURL(link.url); })
                {
                    text      = link.name,
                    tooltip   = link.url,
                    classList = { k_LinkClass }
                }, package.links.First() != link);
            }

            // add links related to the upm version
            if (UpmPackageDocs.HasDocs(version))
            {
                AddToLinks(leftItems, new Button(ViewDocClick)
                {
                    text = k_ViewDocumentationText, classList = { k_LinkClass }
                }, false);
            }

            if (UpmPackageDocs.HasChangelog(version))
            {
                AddToLinks(leftItems, new Button(ViewChangelogClick)
                {
                    text = k_ViewChangelogText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasLicenses(version))
            {
                AddToLinks(leftItems, new Button(ViewLicensesClick)
                {
                    text = k_ViewLicensesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasUseCases(version))
            {
                AddToLinks(leftItems, new Button(ViewUseCasesClick)
                {
                    text = k_ViewUseCasesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasDashboard(version))
            {
                AddToLinks(leftItems, new Button(ViewDashboardClick)
                {
                    text = k_ViewDashboardText, classList = { k_LinkClass }
                });
            }

            var topOffset = false;

            if (package.Is(PackageType.Feature) && !string.IsNullOrEmpty(GetQuickStartUrl(m_Version)))
            {
                var quickStartButton = new Button(ViewQuickStartClick)
                {
                    name = "quickStart", classList = { "quickStartButton", "right" }
                };
                quickStartButton.Add(new VisualElement {
                    classList = { "quickStartIcon" }
                });
                quickStartButton.Add(new TextElement {
                    text = k_ViewQuickStartText, classList = { "quickStartText" }
                });

                Add(quickStartButton);

                topOffset = leftItems.childCount == 0;
            }
            // Offset the links container to the top when there are no links and only quick start button visible
            EnableInClassList("topOffset", topOffset);
            UIUtils.SetElementDisplay(this, childCount != 0);
        }