コード例 #1
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();
        }
コード例 #2
0
        internal void SetDisplayPackage(PackageInfo packageInfo)
        {
            DisplayPackage = packageInfo;

            var   detailVisible = true;
            Error error         = null;

            if (package == null || DisplayPackage == null)
            {
                detailVisible = false;
                UIUtils.SetElementDisplay(DocumentationContainer, false);
                UIUtils.SetElementDisplay(CustomContainer, false);
                UIUtils.SetElementDisplay(UpdateBuiltIn, false);

                foreach (var extension in PackageManagerExtensions.Extensions)
                {
                    extension.OnPackageSelectionChange(null);
                }
            }
            else
            {
                SetUpdateVisibility(true);
                UIUtils.SetElementDisplay(ViewDocButton, true);
                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.preview), DisplayPackage.IsPreview);

                UIUtils.SetElementDisplay(DocumentationContainer, DisplayPackage.Origin != PackageSource.BuiltIn);
                UIUtils.SetElementDisplay(ChangelogContainer, DisplayPackage.HasChangelog(DisplayPackage));

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

                DetailModuleReference.text = "";
                var isBuiltIn = DisplayPackage.IsBuiltIn;
                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);
                }
            }

            // Set visibility
            root.Q <VisualElement>("detail").visible = detailVisible;

            if (null == error)
            {
                error = PackageCollection.Instance.GetPackageError(package);
            }

            if (error != null)
            {
                SetError(error);
            }
            else
            {
                DetailError.ClearError();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
0
        internal void SetDisplayPackage(PackageInfo packageInfo)
        {
            DisplayPackage = packageInfo;

            var   detailVisible = true;
            Error error         = null;

            if (package == null || DisplayPackage == null)
            {
                detailVisible = false;
                UIUtils.SetElementDisplay(DocumentationContainer, false);
                UIUtils.SetElementDisplay(CustomContainer, false);
                UIUtils.SetElementDisplay(UpdateBuiltIn, false);

                foreach (var extension in PackageManagerExtensions.Extensions)
                {
                    extension.OnPackageSelectionChange(null);
                }
            }
            else
            {
                SetUpdateVisibility(true);
                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.HasTag(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);
                }

                foreach (var tag in SupportedTags())
                {
                    UIUtils.SetElementDisplay(GetTag(tag), DisplayPackage.HasTag(tag));
                }

                UIUtils.SetElementDisplay(DocumentationContainer, DisplayPackage.Origin != PackageSource.BuiltIn);
                UIUtils.SetElementDisplay(ChangelogContainer, HasChangelog(DisplayPackage));

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

                DetailModuleReference.text = "";
                var isModule = PackageInfo.IsModule(DisplayPackage.Name);
                if (PackageInfo.IsModule(DisplayPackage.Name))
                {
                    DetailModuleReference.text = DisplayPackage.Description;
                    if (string.IsNullOrEmpty(DisplayPackage.Description))
                    {
                        DetailModuleReference.text = string.Format("This built in package controls the presence of the {0} module.", DisplayPackage.ModuleName);
                    }
                }

                // Show Status string on package if need be
                DetailPackageStatus.text = string.Empty;
                if (!isModule)
                {
                    var displayPackageList = package.Current ?? package.Latest;
                    if (displayPackageList.State == PackageState.Outdated)
                    {
                        DetailPackageStatus.text =
                            "This package is installed for your project and has an available update.";
                    }
                    else if (displayPackageList.State == PackageState.InProgress)
                    {
                        DetailPackageStatus.text =
                            "This package is being updated or installed.";
                    }
                    else if (displayPackageList.State == PackageState.Error)
                    {
                        DetailPackageStatus.text =
                            "This package is in error, please check console logs for more details.";
                    }
                    else if (displayPackageList.IsCurrent)
                    {
                        DetailPackageStatus.text =
                            "This package is installed for your project.";
                    }
                    else
                    {
                        DetailPackageStatus.text =
                            "This package is not installed for your project.";
                    }
                }

                DetailAuthor.text = string.Format("Author: {0}", DisplayPackage.Author ?? "Unity Technologies Inc.");

                UIUtils.SetElementDisplay(DetailDesc, !isModule);
                UIUtils.SetElementDisplay(DetailVersion, !isModule);
                UIUtils.SetElementDisplayNonEmpty(DetailModuleReference);
                UIUtils.SetElementDisplayNonEmpty(DetailPackageStatus);
                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);
                }
            }

            // Set visibility
            root.Q <VisualElement>("detail").visible = detailVisible;
            root.Q <VisualElement>(emptyId).visible  = !detailVisible;

            if (error != null)
            {
                Debug.LogError("Error with package details: " + error.message);
                SetError(error);
            }
            else
            {
                DetailError.ClearError();
            }
        }
コード例 #5
0
        public void SetPackage(Package package, PackageFilter filter)
        {
            if (this.package != null)
            {
                if (this.package.AddSignal.Operation != null)
                {
                    this.package.AddSignal.Operation.OnOperationError   -= OnAddOperationError;
                    this.package.AddSignal.Operation.OnOperationSuccess -= OnAddOperationSuccess;
                }

                if (this.package.RemoveSignal.Operation != null)
                {
                    this.package.RemoveSignal.Operation.OnOperationError -= OnRemoveOperationError;
                }
            }

            this.filter  = filter;
            this.package = package;
            var   detailVisible = true;
            Error error         = null;

            if (package == null || Display(package) == null)
            {
                detailVisible = false;
                UIUtils.SetElementDisplay(ViewChangelogButton, false);
                UIUtils.SetElementDisplay(ViewDocButton, false);
            }
            else
            {
                SetUpdateVisibility(true);
                RemoveButton.visible = true;

                var displayPackage = Display(package);

                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.HasTag(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);
                }

                foreach (var tag in SupportedTags())
                {
                    UIUtils.SetElementDisplay(GetTag(tag), displayPackage.HasTag(tag));
                }

                if (Display(package).Origin == PackageOrigin.Builtin)
                {
                    UIUtils.SetElementDisplay(ViewChangelogButton, false);
                    UIUtils.SetElementDisplay(ViewDocButton, false);
                }
                else
                {
                    var currentVersion = package.Current;
                    var hasUpdate      = currentVersion != null && displayPackage.Version.CompareByPrecedence(currentVersion.Version) > 0;
                    UIUtils.SetElementDisplay(ViewChangelogButton, displayPackage.IsCurrent || hasUpdate);
                    UIUtils.SetElementDisplay(ViewDocButton, true);
                }

                root.Q <Label>("detailName").text = displayPackage.Name;
                root.Q <ScrollView>("detailView").scrollOffset = new Vector2(0, 0);

                DetailModuleReference.text = "";
                var isModule = PackageInfo.IsModule(displayPackage.Name);
                if (PackageInfo.IsModule(displayPackage.Name))
                {
                    DetailModuleReference.text = displayPackage.Description;
                    if (string.IsNullOrEmpty(displayPackage.Description))
                    {
                        DetailModuleReference.text = string.Format("This built in package controls the presence of the {0} module.", displayPackage.ModuleName);
                    }
                }

                // Show Status string on package if need be
                DetailPackageStatus.text = string.Empty;
                if (!isModule)
                {
                    var displayPackageList = package.Current ?? package.Latest;
                    if (displayPackageList.State == PackageState.Outdated)
                    {
                        DetailPackageStatus.text =
                            "This package is installed for your project and has an available update.";
                    }
                    else if (displayPackageList.State == PackageState.InProgress)
                    {
                        DetailPackageStatus.text =
                            "This package is being updated or installed.";
                    }
                    else if (displayPackageList.State == PackageState.Error)
                    {
                        DetailPackageStatus.text =
                            "This package is in error, please check console logs for more details.";
                    }
                    else if (displayPackageList.IsCurrent)
                    {
                        DetailPackageStatus.text =
                            "This package is installed for your project.";
                    }
                    else
                    {
                        DetailPackageStatus.text =
                            "This package is not installed for your project.";
                    }
                }

                DetailAuthor.text = string.Format("Author: {0}", displayPackage.Author ?? "Unity Technologies Inc.");

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


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

                RefreshAddButton();
                RefreshRemoveButton();

                this.package.AddSignal.OnOperation    += OnAddOperation;
                this.package.RemoveSignal.OnOperation += OnRemoveOperation;
            }

            // Set visibility
            root.Q <VisualElement>("detail").visible = detailVisible;
            root.Q <VisualElement>(emptyId).visible  = !detailVisible;

            if (error != null)
            {
                Debug.LogError("Error with package details: " + error.message);
                SetError(error);
            }
            else
            {
                DetailError.ClearError();
            }
        }