예제 #1
0
        public static void HandleInvalidOrUnreachableOnlineUrl(string onlineUrl, string offlineDocPath, string docType, string analyticsEvent, IPackageVersion version, IPackage package, ApplicationProxy applicationProxy)
        {
            if (!string.IsNullOrEmpty(offlineDocPath))
            {
                applicationProxy.RevealInFinder(offlineDocPath);

                PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}OnDisk", version?.uniqueId);
                return;
            }

            if (!string.IsNullOrEmpty(onlineUrl))
            {
                // With the current `UpmPackageDocs.GetDocumentationUrl` implementation,
                // We'll get invalid url links for non-unity packages on unity3d.com
                // We want to avoiding opening these kinds of links to avoid confusion.
                if (!UpmClient.IsUnityUrl(onlineUrl) || package.Is(PackageType.Unity) || version.packageUniqueId.StartsWith("com.unity."))
                {
                    applicationProxy.OpenURL(onlineUrl);

                    PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}UnreachableOrInvalidUrl", version?.uniqueId);
                    return;
                }
            }

            PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}NotFound", version?.uniqueId);

            Debug.LogError(string.Format(L10n.Tr("[Package Manager Window] Unable to find valid {0} for this {1}."), docType, package.GetDescriptor()));
        }
예제 #2
0
        public static void OpenWebUrl(string onlineUrl, IPackageVersion version, ApplicationProxy applicationProxy, string analyticsEvent, Action errorCallback)
        {
            var request = UnityWebRequest.Head(onlineUrl);

            try
            {
                var operation = request.SendWebRequest();
                operation.completed += (op) =>
                {
                    if (request.responseCode >= 200 && request.responseCode < 300)
                    {
                        applicationProxy.OpenURL(onlineUrl);
                        PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}ValidUrl", version?.uniqueId);
                    }
                    else
                    {
                        errorCallback?.Invoke();
                    }
                };
            }
            catch (InvalidOperationException e)
            {
                if (e.Message != "Insecure connection not allowed")
                {
                    throw e;
                }
            }
        }
예제 #3
0
        protected override bool TriggerAction(IList <IPackageVersion> versions)
        {
            var title = string.Format(L10n.Tr("Removing {0} items"), versions.Count);

            var result = 0;

            if (!m_PackageManagerPrefs.skipMultiSelectRemoveConfirmation)
            {
                var message = L10n.Tr("Are you sure you want to remove these items?");
                result = m_Application.DisplayDialogComplex(title, message, L10n.Tr("Remove"), L10n.Tr("Cancel"), L10n.Tr("Never ask"));
            }

            // Cancel
            if (result == 1)
            {
                return(false);
            }

            // Never ask
            if (result == 2)
            {
                m_PackageManagerPrefs.skipMultiSelectRemoveConfirmation = true;
            }

            m_PackageDatabase.Uninstall(versions.Select(v => v.package));
            PackageManagerWindowAnalytics.SendEvent("uninstall", packageIds: versions.Select(v => v.uniqueId));
            // After a bulk removal, we want to deselect them to avoid installing them back by accident.
            DeselectVersions(versions);
            return(true);
        }
예제 #4
0
        protected override bool TriggerAction(IPackageVersion version)
        {
            var packagesToUninstall = m_PackageDatabase.GetCustomizedDependencies(version, true);

            if (!packagesToUninstall.Any())
            {
                return(false);
            }

            var packageNameAndVersions = string.Join("\n\u2022 ",
                                                     packagesToUninstall.Select(package => $"{package.displayName} - {package.versions.lifecycleVersion.version}").ToArray());
            var message = packagesToUninstall.Length == 1 ?
                          string.Format(
                L10n.Tr("Are you sure you want to reset this {0}?\nThe following included package will reset to the required version:\n\u2022 {1}"),
                version.package.GetDescriptor(), packageNameAndVersions) :
                          string.Format(
                L10n.Tr("Are you sure you want to reset this {0}?\nThe following included packages will reset to their required versions:\n\u2022 {1}"),
                version.package.GetDescriptor(), packageNameAndVersions);

            if (!m_Application.DisplayDialog(L10n.Tr("Unity Package Manager"), message, L10n.Tr("Continue"), L10n.Tr("Cancel")))
            {
                return(false);
            }

            m_PageManager.SetPackagesUserUnlockedState(packagesToUninstall.Select(p => p.uniqueId), false);
            m_PackageDatabase.ResetDependencies(version, packagesToUninstall);

            PackageManagerWindowAnalytics.SendEvent("reset", version?.uniqueId);
            return(true);
        }
예제 #5
0
        private void OnImportButtonClicked()
        {
            var previousImports     = m_Sample.previousImports;
            var previousImportPaths = previousImports.Aggregate <string, string>(string.Empty,
                                                                                 (current, next) => current + next.Replace(@"\", "/").Replace(Application.dataPath, "Assets") + "\n");

            var warningMessage = string.Empty;

            if (previousImports.Count > 1)
            {
                warningMessage = L10n.Tr("Different versions of the sample are already imported at") + "\n\n"
                                 + previousImportPaths + "\n" + L10n.Tr("They will be deleted when you update.");
            }
            else if (previousImports.Count == 1)
            {
                if (m_Sample.isImported)
                {
                    warningMessage = L10n.Tr("The sample is already imported at") + "\n\n"
                                     + previousImportPaths + "\n" + L10n.Tr("Importing again will override all changes you have made to it.");
                }
                else
                {
                    warningMessage = L10n.Tr("A different version of the sample is already imported at") + "\n\n"
                                     + previousImportPaths + "\n" + L10n.Tr("It will be deleted when you update.");
                }
            }

            if (!string.IsNullOrEmpty(warningMessage) &&
                !m_ApplicationProxy.DisplayDialog("importPackageSample",
                                                  L10n.Tr("Importing package sample"),
                                                  warningMessage + L10n.Tr(" Are you sure you want to continue?"),
                                                  L10n.Tr("Yes"), L10n.Tr("No")))
            {
                return;
            }

            if (previousImports.Count < 1)
            {
                PackageManagerWindowAnalytics.SendEvent("importSample", m_Version.uniqueId);
            }
            else
            {
                PackageManagerWindowAnalytics.SendEvent("reimportSample", m_Version.uniqueId);
            }

            if (m_Sample.Import(Sample.ImportOptions.OverridePreviousImports))
            {
                RefreshImportStatus();
                if (m_Sample.isImported)
                {
                    // Highlight import path
                    var currentPath        = m_IOProxy.CurrentDirectory;
                    var importRelativePath = m_Sample.importPath.Replace(currentPath + Path.DirectorySeparatorChar, "");
                    var obj = m_AssetDatabase.LoadMainAssetAtPath(importRelativePath);
                    m_Selection.activeObject = obj;
                    EditorGUIUtility.PingObject(obj);
                }
            }
        }
예제 #6
0
 protected override bool TriggerAction(IList <IPackageVersion> versions)
 {
     m_PackageDatabase.Install(versions.Select(v => GetTargetVersion(v)));
     // The current multi-select UI does not allow users to install non-recommended versions
     // Should this change in the future, we'll need to update the analytics event accordingly.
     PackageManagerWindowAnalytics.SendEvent("installUpdateRecommended", packageIds: versions.Select(v => v.uniqueId));
     return(true);
 }
 protected override bool TriggerAction(IPackageVersion version)
 {
     m_PageManager.SetPackagesUserUnlockedState(new string[1] {
         version.packageUniqueId
     }, true);
     PackageManagerWindowAnalytics.SendEvent("unlock", version.packageUniqueId);
     return(true);
 }
예제 #8
0
 private void ShowReadMoreLink(UIError error, IPackageVersion packageVersion)
 {
     m_ReadMoreLinkAction = () =>
     {
         PackageManagerWindowAnalytics.SendEvent($"alertreadmore_{error.errorCode.ToString()}", packageVersion?.uniqueId);
         Application.OpenURL(error.readMoreURL);
     };
     UIUtils.SetElementDisplay(alertReadMoreLink, true);
 }
 protected override bool TriggerAction(IList <IPackageVersion> versions)
 {
     m_PageManager.RemoveSelection(versions.Select(v => new PackageAndVersionIdPair(v.packageUniqueId, v.uniqueId)));
     if (!string.IsNullOrEmpty(m_AnalyticsEventName))
     {
         PackageManagerWindowAnalytics.SendEvent(m_AnalyticsEventName, packageIds: versions.Select(v => v.packageUniqueId));
     }
     return(true);
 }
예제 #10
0
        protected override bool TriggerAction(IPackageVersion version)
        {
            var canDownload = m_PackageDatabase.Download(version.package);

            if (canDownload)
            {
                PackageManagerWindowAnalytics.SendEvent("startDownloadNew", version.packageUniqueId);
            }
            return(canDownload);
        }
예제 #11
0
        protected override bool TriggerAction(IList <IPackageVersion> versions)
        {
            var canDownload = m_PackageDatabase.Download(versions.Select(v => v.package));

            if (canDownload)
            {
                PackageManagerWindowAnalytics.SendEvent("startDownloadNew", packageIds: versions.Select(v => v.packageUniqueId));
            }
            return(canDownload);
        }
예제 #12
0
        private void AuthorClick()
        {
            var authorLink = m_Version?.authorLink ?? string.Empty;

            if (!string.IsNullOrEmpty(authorLink))
            {
                m_Application.OpenURL(authorLink);
                PackageManagerWindowAnalytics.SendEvent("viewAuthorLink", m_Version?.uniqueId);
            }
        }
예제 #13
0
        private void SetFilterFromMenu(PackageFilterTab filter)
        {
            if (filter == m_PackageFiltering.currentFilterTab)
            {
                return;
            }

            SetCurrentSearch(string.Empty);
            SetFilter(filter);
            PackageManagerWindowAnalytics.SendEvent("changeFilter");
        }
예제 #14
0
        private void ShowOthersVersion()
        {
            if (m_Version?.package == null)
            {
                return;
            }

            m_PageManager.SetSeeAllVersions(m_Version.package, true);
            PackageManagerWindowAnalytics.SendEvent("seeAllVersions", m_Version.package.uniqueId);

            Refresh(m_Version);
        }
예제 #15
0
 private void DelayedSearchEvent()
 {
     if (DateTime.Now.Ticks - m_SearchTextChangeTimestamp > k_SearchEventDelayTicks)
     {
         EditorApplication.update -= DelayedSearchEvent;
         var value = searchToolbar.value.Trim();
         m_PackageFiltering.currentSearchText = value;
         if (!string.IsNullOrEmpty(value))
         {
             PackageManagerWindowAnalytics.SendEvent("search");
         }
     }
 }
        protected override bool TriggerAction(IPackageVersion version)
        {
            if (version.HasTag(PackageTag.Custom))
            {
                if (!m_Application.DisplayDialog(L10n.Tr("Unity Package Manager"), L10n.Tr("You will lose all your changes (if any) if you delete a package in development. Are you sure?"), L10n.Tr("Yes"), L10n.Tr("No")))
                {
                    return(false);
                }

                m_PackageDatabase.RemoveEmbedded(version.package);
                PackageManagerWindowAnalytics.SendEvent("removeEmbedded", version.uniqueId);
                return(true);
            }

            return(false);
        }
예제 #17
0
        protected override bool TriggerAction(IPackageVersion version)
        {
            IPackage[] packageToUninstall = null;
            if (version.HasTag(PackageTag.Feature))
            {
                var customizedDependencies = m_PackageDatabase.GetCustomizedDependencies(version, true);
                if (customizedDependencies.Any())
                {
                    var packageNameAndVersions = string.Join("\n\u2022 ",
                                                             customizedDependencies.Select(package => $"{package.displayName} - {package.versions.lifecycleVersion.version}").ToArray());

                    var title   = string.Format(L10n.Tr("Installing {0}"), version.package.GetDescriptor());
                    var message = customizedDependencies.Length == 1 ?
                                  string.Format(
                        L10n.Tr("This {0} includes a package version that is different from what's already installed. Would you like to reset the following package to the required version?\n\u2022 {1}"),
                        version.package.GetDescriptor(), packageNameAndVersions) :
                                  string.Format(
                        L10n.Tr("This {0} includes package versions that are different from what are already installed. Would you like to reset the following packages to the required versions?\n\u2022 {1}"),
                        version.package.GetDescriptor(), packageNameAndVersions);

                    var result = m_Application.DisplayDialogComplex("installPackageWithCustomizedDependencies", title, message, L10n.Tr("Install and Reset"), L10n.Tr("Cancel"), L10n.Tr("Install Only"));
                    if (result == 1) // Cancel
                    {
                        return(false);
                    }
                    if (result == 0) // Install and reset
                    {
                        packageToUninstall = customizedDependencies;
                    }
                }
            }

            if (packageToUninstall?.Any() == true)
            {
                m_PackageDatabase.InstallAndResetDependencies(version, packageToUninstall);
                PackageManagerWindowAnalytics.SendEvent("installAndReset", version.uniqueId);
            }
            else
            {
                m_PackageDatabase.Install(version);

                var installRecommended = version.package.versions.recommended == version ? "Recommended" : "NonRecommended";
                var eventName          = $"installNew{installRecommended}";
                PackageManagerWindowAnalytics.SendEvent(eventName, version.uniqueId);
            }
            return(true);
        }
예제 #18
0
        public void AddDropdownItem(DropdownMenu menu, int value)
        {
            var textValue = value == (int)AssetsToLoad.All ? k_All : value.ToString();

            textValue = L10n.Tr(textValue);
            menu.AppendAction(textValue, a =>
            {
                loadAssetsDropdown.text    = textValue;
                m_SettingsProxy.loadAssets = value;
                m_SettingsProxy.Save();
                UpdateLoadBarMessage();
                LoadItemsClicked();
                UpdateMenu();

                PackageManagerWindowAnalytics.SendEvent($"load {value}");
            }, a => m_SettingsProxy.loadAssets == value ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal);
        }
        private void InstallByNameAndVersion(string packageName, string packageVersion = null)
        {
            var packageId = string.IsNullOrEmpty(packageVersion) ? packageName : $"{packageName}@{packageVersion}";

            m_UpmClient.AddById(packageId);

            PackageManagerWindowAnalytics.SendEvent("addByNameAndVersion", packageId);

            Close();

            var package = m_PackageDatabase.GetPackage(packageName);

            if (package != null)
            {
                m_PackageFiltering.currentFilterTab = m_PageManager.FindTab(package);
                m_PageManager.SetSelected(package, package.versions?.FirstOrDefault(v => v.versionString == packageVersion));
            }
        }
        private static void OnConfigureClicked(PackageSelectionArgs args)
        {
            var database         = ServicesContainer.instance.Resolve <PackageDatabase>();
            var package          = database.GetPackage(args.package.uniqueId);
            var installedVersion = package?.versions?.installed;

            if (installedVersion == null)
            {
                return;
            }

            var editorGameService = GetEditorGameServiceField(installedVersion.packageInfo);
            var configurePath     = GetConfigurePathField(editorGameService);

            if (!string.IsNullOrEmpty(configurePath))
            {
                PackageManagerWindowAnalytics.SendEvent("configureService", args.package.uniqueId);
            }
            SettingsService.OpenProjectSettings(configurePath);
        }
        private void Refresh(IPage page = null)
        {
            if (page == null)
            {
                page = m_PageManager.GetCurrentPage();
            }
            var showOnFilterTab = page.subPages.Skip(1).Any();

            UIUtils.SetElementDisplay(this, showOnFilterTab);

            if (!showOnFilterTab)
            {
                return;
            }

            Clear();
            var currentSubPage = page.currentSubPage;

            foreach (var subPage in page.subPages)
            {
                var button = new Button();
                button.text = subPage.displayName;
                button.clickable.clicked += () =>
                {
                    if (page.currentSubPage == subPage)
                    {
                        return;
                    }
                    page.currentSubPage = subPage;
                    PackageManagerWindowAnalytics.SendEvent("changeSubPage");
                };
                Add(button);
                if (subPage == currentSubPage)
                {
                    button.AddToClassList("active");
                }
            }
        }
예제 #22
0
 private void SeeAllVersionsClick()
 {
     m_PageManager.SetSeeAllVersions(package, true);
     PackageManagerWindowAnalytics.SendEvent("seeAllVersions", targetVersion?.uniqueId);
 }
예제 #23
0
        private void SetupAdvancedMenu()
        {
            toolbarSettingsMenu.tooltip = L10n.Tr("Advanced");

            var dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem();

            dropdownItem.text   = L10n.Tr("Project Settings");
            dropdownItem.action = () =>
            {
                if (!m_SettingsProxy.advancedSettingsExpanded)
                {
                    m_SettingsProxy.advancedSettingsExpanded = true;
                    m_SettingsProxy.Save();
                }
                SettingsWindow.Show(SettingsScope.Project, PackageManagerProjectSettingsProvider.k_PackageManagerSettingsPath);
                PackageManagerWindowAnalytics.SendEvent("advancedProjectSettings");
            };

            dropdownItem        = toolbarSettingsMenu.AddBuiltInDropdownItem();
            dropdownItem.text   = L10n.Tr("Preferences");
            dropdownItem.action = () =>
            {
                SettingsWindow.Show(SettingsScope.User, PackageManagerUserSettingsProvider.k_PackageManagerUserSettingsPath);
                PackageManagerWindowAnalytics.SendEvent("packageManagerUserSettings");
            };

            dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem();
            dropdownItem.insertSeparatorBefore = true;
            dropdownItem.text   = L10n.Tr("Manual resolve");
            dropdownItem.action = () =>
            {
                if (!EditorApplication.isPlaying)
                {
                    m_UpmClient.Resolve();
                }
            };

            dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem();
            dropdownItem.insertSeparatorBefore = true;
            dropdownItem.text   = L10n.Tr("Reset Packages to defaults");
            dropdownItem.action = () =>
            {
                EditorApplication.ExecuteMenuItem(k_ResetPackagesMenuPath);
                m_PageManager.Refresh(RefreshOptions.UpmListOffline);
                PackageManagerWindowAnalytics.SendEvent("resetToDefaults");
            };

            if (Unsupported.IsDeveloperBuild())
            {
                dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem();
                dropdownItem.insertSeparatorBefore = true;
                dropdownItem.text   = L10n.Tr("Reset Package Database");
                dropdownItem.action = () =>
                {
                    PackageManagerWindow.instance?.Close();
                    m_PageManager.Reload();
                    ServicesContainer.instance.Resolve <AssetStoreCallQueue>().ClearFetchDetails();
                };

                dropdownItem        = toolbarSettingsMenu.AddBuiltInDropdownItem();
                dropdownItem.text   = L10n.Tr("Reset Stylesheets");
                dropdownItem.action = () =>
                {
                    PackageManagerWindow.instance?.Close();
                    m_ResourceLoader.Reset();
                };
            }
        }
예제 #24
0
        protected override bool TriggerAction(IPackageVersion version)
        {
            var result = 0;

            if (version.HasTag(PackageTag.BuiltIn))
            {
                if (!m_PackageManagerPrefs.skipDisableConfirmation)
                {
                    result = m_Application.DisplayDialogComplex(L10n.Tr("Disable Built-In Package"),
                                                                L10n.Tr("Are you sure you want to disable this built-in package?"),
                                                                L10n.Tr("Disable"), L10n.Tr("Cancel"), L10n.Tr("Never ask"));
                }
            }
            else
            {
                var isPartOfFeature = m_PackageDatabase.GetFeatureDependents(version).Any(featureSet => featureSet.isInstalled);
                if (isPartOfFeature || !m_PackageManagerPrefs.skipRemoveConfirmation)
                {
                    var descriptor = version.package.GetDescriptor();
                    var title      = string.Format(L10n.Tr("Removing {0}"), CultureInfo.InvariantCulture.TextInfo.ToTitleCase(descriptor));
                    if (isPartOfFeature)
                    {
                        var message  = string.Format(L10n.Tr("Are you sure you want to remove this {0} that is used by at least one installed feature?"), descriptor);
                        var removeIt = m_Application.DisplayDialog(title, message, L10n.Tr("Remove"), L10n.Tr("Cancel"));
                        result = removeIt ? 0 : 1;
                    }
                    else
                    {
                        var message = string.Format(L10n.Tr("Are you sure you want to remove this {0}?"), descriptor);
                        result = m_Application.DisplayDialogComplex(title, message, L10n.Tr("Remove"), L10n.Tr("Cancel"), L10n.Tr("Never ask"));
                    }
                }
            }

            // Cancel
            if (result == 1)
            {
                return(false);
            }

            // Do not ask again
            if (result == 2)
            {
                if (version.HasTag(PackageTag.BuiltIn))
                {
                    m_PackageManagerPrefs.skipDisableConfirmation = true;
                }
                else
                {
                    m_PackageManagerPrefs.skipRemoveConfirmation = true;
                }
            }

            // If the user is removing a package that is part of a feature set, lock it after removing from manifest
            // Having this check condition should be more optimal once we implement caching of Feature Set Dependents for each package
            if (m_PackageDatabase.GetFeatureDependents(version.package.versions.installed)?.Any() == true)
            {
                m_PageManager.SetPackagesUserUnlockedState(new List <string> {
                    version.packageUniqueId
                }, false);
            }

            // Remove
            m_PackageDatabase.Uninstall(version.package);
            PackageManagerWindowAnalytics.SendEvent("uninstall", version?.uniqueId);
            return(true);
        }
예제 #25
0
        private void SetupAddMenu()
        {
            var dropdownItem = addMenu.AddBuiltInDropdownItem();

            dropdownItem.text     = L10n.Tr("Add package from disk...");
            dropdownItem.userData = "AddFromDisk";
            dropdownItem.action   = () =>
            {
                var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "package.json file", "json" });
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                try
                {
                    if (m_IOProxy.GetFileName(path) != "package.json")
                    {
                        Debug.Log(L10n.Tr("[Package Manager Window] Please select a valid package.json file in a package folder."));
                        return;
                    }


                    if (!m_PackageDatabase.isInstallOrUninstallInProgress)
                    {
                        m_PackageDatabase.InstallFromPath(m_IOProxy.GetParentDirectory(path), out var tempPackageId);
                        PackageManagerWindowAnalytics.SendEvent("addFromDisk");

                        var package = m_PackageDatabase.GetPackage(tempPackageId);
                        if (package != null)
                        {
                            m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject;
                            m_PageManager.SetSelected(package);
                        }
                    }
                }
                catch (System.IO.IOException e)
                {
                    Debug.Log($"[Package Manager Window] Cannot add package from disk {path}: {e.Message}");
                }
            };

            dropdownItem          = addMenu.AddBuiltInDropdownItem();
            dropdownItem.text     = L10n.Tr("Add package from tarball...");
            dropdownItem.userData = "AddFromTarball";
            dropdownItem.action   = () =>
            {
                var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "Package tarball", "tgz, tar.gz" });
                if (!string.IsNullOrEmpty(path) && !m_PackageDatabase.isInstallOrUninstallInProgress)
                {
                    m_PackageDatabase.InstallFromPath(path, out var tempPackageId);
                    PackageManagerWindowAnalytics.SendEvent("addFromTarball");

                    var package = m_PackageDatabase.GetPackage(tempPackageId);
                    if (package != null)
                    {
                        m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject;
                        m_PageManager.SetSelected(package);
                    }
                }
            };

            dropdownItem          = addMenu.AddBuiltInDropdownItem();
            dropdownItem.text     = L10n.Tr("Add package from git URL...");
            dropdownItem.userData = "AddFromGit";
            dropdownItem.action   = () =>
            {
                var args = new InputDropdownArgs
                {
                    title            = L10n.Tr("Add package from git URL"),
                    iconUssClass     = "git",
                    placeholderText  = L10n.Tr("URL"),
                    submitButtonText = L10n.Tr("Add"),
                    onInputSubmitted = url =>
                    {
                        if (!m_PackageDatabase.isInstallOrUninstallInProgress)
                        {
                            m_PackageDatabase.InstallFromUrl(url);
                            PackageManagerWindowAnalytics.SendEvent("addFromGitUrl", url);

                            var package = m_PackageDatabase.GetPackage(url);
                            if (package != null)
                            {
                                m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject;
                                m_PageManager.SetSelected(package);
                            }
                        }
                    },
                    windowSize = new Vector2(resolvedStyle.width, 50)
                };
                addMenu.ShowInputDropdown(args);
            };

            dropdownItem          = addMenu.AddBuiltInDropdownItem();
            dropdownItem.text     = L10n.Tr("Add package by name...");
            dropdownItem.userData = "AddByName";
            dropdownItem.action   = () =>
            {
                // Same as above, the worldBound of the toolbar is used rather than the addMenu
                var rect     = GUIUtility.GUIToScreenRect(worldBound);
                var dropdown = new AddPackageByNameDropdown(m_ResourceLoader, m_PackageFiltering, m_UpmClient, m_PackageDatabase, m_PageManager, PackageManagerWindow.instance)
                {
                    position = rect
                };
                DropdownContainer.ShowDropdown(dropdown);
            };
        }
예제 #26
0
 protected override bool TriggerAction(IList <IPackageVersion> versions)
 {
     m_PackageDatabase.AbortDownload(versions.Select(v => v.package));
     PackageManagerWindowAnalytics.SendEvent("abortDownload", packageIds: versions.Select(v => v.packageUniqueId));
     return(true);
 }
예제 #27
0
        protected override bool TriggerAction(IPackageVersion version)
        {
            var installedVersion = version.package.versions.installed;
            var targetVersion    = GetTargetVersion(version);

            if (installedVersion != null && !installedVersion.isDirectDependency && installedVersion != targetVersion)
            {
                var featureSetDependents = m_PackageDatabase.GetFeatureDependents(installedVersion);
                // if the installed version is being used by a Feature Set show the more specific
                //  Feature Set dialog instead of the generic one
                if (featureSetDependents.Any())
                {
                    var message = string.Format(L10n.Tr("Changing a {0} that is part of a feature can lead to errors. Are you sure you want to proceed?"), version.package.GetDescriptor());
                    if (!m_Application.DisplayDialog(L10n.Tr("Warning"), message, L10n.Tr("Yes"), L10n.Tr("No")))
                    {
                        return(false);
                    }
                }
                else
                {
                    var message = L10n.Tr("This version of the package is being used by other packages. Upgrading a different version might break your project. Are you sure you want to continue?");
                    if (!m_Application.DisplayDialog(L10n.Tr("Unity Package Manager"), message, L10n.Tr("Yes"), L10n.Tr("No")))
                    {
                        return(false);
                    }
                }
            }

            IPackage[] packageToUninstall = null;
            if (targetVersion.HasTag(PackageTag.Feature))
            {
                var customizedDependencies = m_PackageDatabase.GetCustomizedDependencies(targetVersion, true);
                if (customizedDependencies.Any())
                {
                    var packageNameAndVersions = string.Join("\n\u2022 ",
                                                             customizedDependencies.Select(package => $"{package.displayName} - {package.versions.lifecycleVersion.version}").ToArray());

                    var message = customizedDependencies.Length == 1 ?
                                  string.Format(
                        L10n.Tr("This {0} includes a package version that is different from what's already installed. Would you like to reset the following package to the required version?\n\u2022 {1}"),
                        version.package.GetDescriptor(), packageNameAndVersions) :
                                  string.Format(
                        L10n.Tr("This {0} includes package versions that are different from what are already installed. Would you like to reset the following packages to the required versions?\n\u2022 {1}"),
                        version.package.GetDescriptor(), packageNameAndVersions);

                    var result = m_Application.DisplayDialogComplex(L10n.Tr("Unity Package Manager"), message, L10n.Tr("Install and Reset"), L10n.Tr("Cancel"), L10n.Tr("Install Only"));
                    if (result == 1) // Cancel
                    {
                        return(false);
                    }
                    if (result == 0) // Install and reset
                    {
                        packageToUninstall = customizedDependencies;
                    }
                }
            }

            if (packageToUninstall?.Any() == true)
            {
                m_PackageDatabase.InstallAndResetDependencies(targetVersion, packageToUninstall);
                PackageManagerWindowAnalytics.SendEvent("installAndReset", targetVersion?.uniqueId);
            }
            else
            {
                m_PackageDatabase.Install(targetVersion);

                var installRecommended = version.package.versions.recommended == targetVersion ? "Recommended" : "NonRecommended";
                var eventName          = $"installUpdate{installRecommended}";
                PackageManagerWindowAnalytics.SendEvent(eventName, targetVersion?.uniqueId);
            }
            return(true);
        }
예제 #28
0
 protected override bool TriggerAction(IPackageVersion version)
 {
     m_PackageDatabase.AbortDownload(version.package);
     PackageManagerWindowAnalytics.SendEvent("abortDownload", version.packageUniqueId);
     return(true);
 }
예제 #29
0
 private void OnDeselectLockedSelectionsClicked()
 {
     m_PageManager.RemoveSelection(m_UnlockFoldout.versions.Select(s => new PackageAndVersionIdPair(s.packageUniqueId, s.uniqueId)));
     PackageManagerWindowAnalytics.SendEvent("deselectLocked", packageIds: m_UnlockFoldout.versions.Select(v => v.packageUniqueId));
 }
예제 #30
0
        public PackageManagerProjectSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null)
            : base(path, scopes, keywords)
        {
            activateHandler = (s, element) =>
            {
                ResolveDependencies();

                // Create a child to make sure all the style sheets are not added to the root.
                rootVisualElement = new ScrollView();
                rootVisualElement.StretchToParentSize();
                rootVisualElement.AddStyleSheetPath(StylesheetPath.scopedRegistriesSettings);
                rootVisualElement.AddStyleSheetPath(StylesheetPath.projectSettings);
                rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? StylesheetPath.stylesheetDark : StylesheetPath.stylesheetLight);
                rootVisualElement.AddStyleSheetPath(StylesheetPath.stylesheetCommon);
                rootVisualElement.styleSheets.Add(m_ResourceLoader.packageManagerCommonStyleSheet);

                element.Add(rootVisualElement);

                m_GeneralTemplate = EditorGUIUtility.Load(k_GeneralServicesTemplatePath) as VisualTreeAsset;

                VisualElement newVisualElement = new VisualElement();
                m_GeneralTemplate.CloneTree(newVisualElement);
                rootVisualElement.Add(newVisualElement);

                cache = new VisualElementCache(rootVisualElement);

                advancedSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.advancedSettingsExpanded);
                m_SettingsProxy.onAdvancedSettingsFoldoutChanged += OnAdvancedSettingsFoldoutChanged;
                advancedSettingsFoldout.RegisterValueChangedCallback(changeEvent =>
                {
                    if (changeEvent.target == advancedSettingsFoldout)
                    {
                        m_SettingsProxy.advancedSettingsExpanded = changeEvent.newValue;
                    }
                });

                scopedRegistriesSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.scopedRegistriesSettingsExpanded);
                m_SettingsProxy.onScopedRegistriesSettingsFoldoutChanged += OnScopedRegistriesSettingsFoldoutChanged;
                scopedRegistriesSettingsFoldout.RegisterValueChangedCallback(changeEvent =>
                {
                    if (changeEvent.target == scopedRegistriesSettingsFoldout)
                    {
                        m_SettingsProxy.scopedRegistriesSettingsExpanded = changeEvent.newValue;
                    }
                });

                preReleaseInfoBox.Q <Button>().clickable.clicked += () =>
                {
                    m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-preview.html");
                };

                enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages);
                enablePreReleasePackages.RegisterValueChangedCallback(changeEvent =>
                {
                    var newValue = changeEvent.newValue;

                    if (newValue != m_SettingsProxy.enablePreReleasePackages)
                    {
                        var saveIt = true;
                        if (newValue && !m_SettingsProxy.oneTimeWarningShown)
                        {
                            if (m_ApplicationProxy.DisplayDialog("showPreReleasePackages", L10n.Tr("Show pre-release packages"), k_Message, L10n.Tr("I understand"), L10n.Tr("Cancel")))
                            {
                                m_SettingsProxy.oneTimeWarningShown = true;
                            }
                            else
                            {
                                saveIt = false;
                            }
                        }

                        if (saveIt)
                        {
                            m_SettingsProxy.enablePreReleasePackages = newValue;
                            m_SettingsProxy.Save();
                            PackageManagerWindowAnalytics.SendEvent("togglePreReleasePackages");
                        }
                    }
                    enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages);
                });

                UIUtils.SetElementDisplay(seeAllPackageVersions, Unsupported.IsDeveloperBuild());
                seeAllPackageVersions.SetValueWithoutNotify(m_SettingsProxy.seeAllPackageVersions);

                seeAllPackageVersions.RegisterValueChangedCallback(changeEvent =>
                {
                    seeAllPackageVersions.SetValueWithoutNotify(changeEvent.newValue);
                    var newValue = changeEvent.newValue;

                    if (newValue != m_SettingsProxy.seeAllPackageVersions)
                    {
                        m_SettingsProxy.seeAllPackageVersions = newValue;
                        m_SettingsProxy.Save();
                    }
                });
            };
        }