コード例 #1
0
        private void SetDisplayPackage(PackageInfo packageInfo, Error packageError = null)
        {
            DisplayPackage = packageInfo;

            Error error = null;

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

            if (!detailVisible)
            {
                foreach (var extension in PackageManagerExtensions.Extensions)
                {
                    extension.OnPackageSelectionChange(null);
                }
            }
            else
            {
                SetUpdateVisibility(true);
                var isBuiltIn = DisplayPackage.IsBuiltIn;
                UIUtils.SetElementDisplay(ViewDocButton, true);
                UIUtils.SetElementDisplay(ViewLicensesContainer, !isBuiltIn);
                RemoveButton.visible = true;

                if (string.IsNullOrEmpty(DisplayPackage.Description))
                {
                    DetailDesc.text = "There is no description for this package.";
                    DetailDesc.AddToClassList(emptyDescriptionClass);
                }
                else
                {
                    DetailDesc.text = DisplayPackage.Description;
                    DetailDesc.RemoveFromClassList(emptyDescriptionClass);
                }

                root.Q <Label>("detailTitle").text = DisplayPackage.DisplayName;
                DetailVersion.text = "Version " + DisplayPackage.VersionWithoutTag;

                if (DisplayPackage.IsInDevelopment || DisplayPackage.HasVersionTag(PackageTag.preview))
                {
                    UIUtils.SetElementDisplay(GetTag(PackageTag.verified), false);
                }
                else
                {
                    var unityVersionParts = Application.unityVersion.Split('.');
                    var unityVersion      = string.Format("{0}.{1}", unityVersionParts[0], unityVersionParts[1]);
                    VerifyLabel.text = unityVersion + " verified";
                    UIUtils.SetElementDisplay(GetTag(PackageTag.verified), DisplayPackage.IsVerified);
                }

                UIUtils.SetElementDisplay(GetTag(PackageTag.inDevelopment), DisplayPackage.IsInDevelopment);
                UIUtils.SetElementDisplay(GetTag(PackageTag.local), DisplayPackage.IsLocal);
                UIUtils.SetElementDisplay(GetTag(PackageTag.git), DisplayPackage.IsGit);
                UIUtils.SetElementDisplay(GetTag(PackageTag.preview), DisplayPackage.IsPreview);

                UIUtils.SetElementDisplay(DocumentationContainer, true);
                UIUtils.SetElementDisplay(ChangelogContainer, DisplayPackage.HasChangelog);

                SampleList.SetPackage(DisplayPackage);

                root.Q <Label>("detailName").text = DisplayPackage.Name;
                DetailScrollView.scrollOffset     = new Vector2(0, 0);

                DetailModuleReference.text = "";
                if (isBuiltIn)
                {
                    DetailModuleReference.text = DisplayPackage.BuiltInDescription;
                }

                DetailAuthor.text = "";
                if (!string.IsNullOrEmpty(DisplayPackage.Author))
                {
                    DetailAuthor.text = string.Format("Author: {0}", DisplayPackage.Author);
                }

                UIUtils.SetElementDisplay(DetailDesc, !isBuiltIn);
                UIUtils.SetElementDisplay(DetailVersion, !isBuiltIn);
                UIUtils.SetElementDisplayNonEmpty(DetailModuleReference);
                UIUtils.SetElementDisplayNonEmpty(DetailAuthor);

                if (DisplayPackage.Errors.Count > 0)
                {
                    error = DisplayPackage.Errors.First();
                }

                RefreshAddButton();
                RefreshRemoveButton();
                UIUtils.SetElementDisplay(CustomContainer, true);

                package.AddSignal.OnOperation    += OnAddOperation;
                package.RemoveSignal.OnOperation += OnRemoveOperation;
                foreach (var extension in PackageManagerExtensions.Extensions)
                {
                    extension.OnPackageSelectionChange(DisplayPackage.Info);
                }

                ShowDependencies();
            }

            // Set visibility
            SetContentVisibility(detailVisible);

            if (packageError == null && package != null && package.Error != null)
            {
                packageError = package.Error;
            }
            if (null == error)
            {
                error = packageError;
            }

            if (error != null)
            {
                SetError(error);
            }
            else
            {
                DetailError.ClearError();
            }
        }
コード例 #2
0
        private void SetDisplayPackage(PackageInfo packageInfo, Error packageError = null)
        {
            DisplayPackage = packageInfo;

            Error error = null;

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

            if (!detailVisible)
            {
                RefreshExtensions(null);
            }
            else
            {
                SetUpdateVisibility(true);
                var isBuiltIn = DisplayPackage.IsBuiltIn;
                UIUtils.SetElementDisplay(ViewDocButton, true);
                UIUtils.SetElementDisplay(ViewLicensesContainer, !isBuiltIn);
                RemoveButton.visible = true;

                if (string.IsNullOrEmpty(DisplayPackage.Description))
                {
                    DetailDesc.text = "There is no description for this package.";
                    DetailDesc.AddToClassList(emptyDescriptionClass);
                }
                else
                {
                    DetailDesc.text = DisplayPackage.Description;
                    DetailDesc.RemoveFromClassList(emptyDescriptionClass);
                }

                root.Q <Label>("detailTitle").text = DisplayPackage.DisplayName;
                DetailVersion.text = "Version " + DisplayPackage.VersionWithoutTag;

                if (DisplayPackage.IsInDevelopment || DisplayPackage.HasVersionTag(PackageTag.preview))
                {
                    UIUtils.SetElementDisplay(GetTag(PackageTag.verified), false);
                }
                else
                {
                    var unityVersionParts = Application.unityVersion.Split('.');
                    var unityVersion      = string.Format("{0}.{1}", unityVersionParts[0], unityVersionParts[1]);
                    VerifyLabel.text = unityVersion + " verified";
                    UIUtils.SetElementDisplay(GetTag(PackageTag.verified), DisplayPackage.IsVerified);
                }

                UIUtils.SetElementDisplay(GetTag(PackageTag.inDevelopment), DisplayPackage.IsInDevelopment);
                UIUtils.SetElementDisplay(GetTag(PackageTag.local), DisplayPackage.IsLocal);
                UIUtils.SetElementDisplay(GetTag(PackageTag.git), DisplayPackage.IsGit);
                UIUtils.SetElementDisplay(GetTag(PackageTag.preview), DisplayPackage.IsPreview);
                UIUtils.SetElementDisplay(EditPackageManifestButton, DisplayPackage.IsInstalled && !package.IsBuiltIn);

                UIUtils.SetElementDisplay(DocumentationContainer, true);
                UIUtils.SetElementDisplay(ChangelogContainer, DisplayPackage.HasChangelog);

                SampleList.SetPackage(DisplayPackage);

                root.Q <Label>("detailName").text = DisplayPackage.Name;
                DetailScrollView.scrollOffset     = new Vector2(0, 0);

                DetailModuleReference.text = "";
                if (isBuiltIn)
                {
                    DetailModuleReference.text = DisplayPackage.BuiltInDescription;
                }

                DetailAuthor.text = "";
                if (!string.IsNullOrEmpty(DisplayPackage.Author))
                {
                    DetailAuthor.text = string.Format("Author: {0}", DisplayPackage.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 (DisplayPackage.Info != null && !DisplayPackage.IsInDevelopment)
                    {
                        if (DisplayPackage.Info.datePublished != null)
                        {
                            DetailDate.text = $"Published Date: {DisplayPackage.Info.datePublished.Value:MMMM dd,  yyyy}";
                        }
                        else if (DisplayPackage.IsCore || DisplayPackage.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(DetailDesc, !isBuiltIn);
                UIUtils.SetElementDisplay(DetailVersion, !isBuiltIn);
                UIUtils.SetElementDisplayNonEmpty(DetailModuleReference);
                UIUtils.SetElementDisplayNonEmpty(DetailAuthor);
                UIUtils.SetElementDisplayNonEmpty(DetailDate);

                if (DisplayPackage.Errors.Count > 0)
                {
                    error = DisplayPackage.Errors.First();
                }

                RefreshAddButton();
                RefreshRemoveButton();
                RefreshDevelopButton();

                UIUtils.SetElementDisplay(CustomContainer, true);

                package.AddSignal.OnOperation    += OnAddOperation;
                package.RemoveSignal.OnOperation += OnRemoveOperation;
                package.EmbedSignal.OnOperation  += OnDevelopOperation;
                RefreshExtensions(DisplayPackage);

                ShowDependencies();
            }
            OnEditorSelectionChanged();

            // Set visibility
            SetContentVisibility(detailVisible);

            if (packageError == null && package != null && package.Error != null)
            {
                packageError = package.Error;
            }
            if (null == error)
            {
                error = packageError;
            }

            if (error != null)
            {
                SetError(error);
            }
            else
            {
                DetailError.ClearError();
            }
        }