private void RemoveRegistryClicked() { if (draft.original != null) { string message; if (AnyPackageInstalledFromRegistry(draft.original.name)) { message = L10n.Tr("There are packages in your project that are from this scoped registry, please remove them before removing the scoped registry."); m_ApplicationProxy.DisplayDialog("cannotDeleteScopedRegistry", L10n.Tr("Cannot delete scoped registry"), message, L10n.Tr("Ok")); return; } message = L10n.Tr("You are about to delete a scoped registry, are you sure you want to continue?"); var deleteRegistry = m_ApplicationProxy.isBatchMode || m_ApplicationProxy.DisplayDialog("deleteScopedRegistry", L10n.Tr("Deleting a scoped registry"), message, L10n.Tr("Ok"), L10n.Tr("Cancel")); if (deleteRegistry) { draft.RegisterWithOriginalOnUndo(k_RemoveRegistry); m_UpmRegistryClient.RemoveRegistry(draft.original.name); } } else { if (!ShowUnsavedChangesDialog()) { return; } m_SettingsProxy.isUserAddingNewScopedRegistry = false; RevertChanges(); } }
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); }
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); } } }
private void OnAssetStoreCacheConfigChange(CachePathConfig config) { if ((config.status == ConfigStatus.Success || config.status == ConfigStatus.ReadOnly) && IsAnyDownloadInProgressOrPause()) { if (!m_Application.isBatchMode) { m_Application.DisplayDialog(L10n.Tr("Package Manager"), L10n.Tr("The Assets Cache location has been changed, all current downloads will be aborted."), L10n.Tr("Ok")); } AbortAllDownloads(); } }
private void OnTermOfServiceAgreementStatusChange(TermOfServiceAgreementStatus status) { if (status == TermOfServiceAgreementStatus.Accepted) { return; } var result = m_Application.DisplayDialog(L10n.Tr("Package Manager"), L10n.Tr("You need to accept Asset Store Terms of Service and EULA before you can download/update any package."), L10n.Tr("Read and accept"), L10n.Tr("Close")); if (result) { m_UnityConnectProxy.OpenAuthorizedURLInWebBrowser(k_TermsOfServicesURL); } }
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); }
private bool CancelDownloadInProgress() { if (!m_AssetStoreDownloadManager.IsAnyDownloadInProgressOrPause()) { return(true); } if (m_ApplicationProxy.isBatchMode || !m_ApplicationProxy.DisplayDialog(L10n.Tr("Package Manager"), L10n.Tr("Changing the Assets Cache location will abort all downloads in progress."), L10n.Tr("Continue"), L10n.Tr("Cancel"))) { return(false); } m_AssetStoreDownloadManager.AbortAllDownloads(); return(true); }
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); }
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); }
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(); } }); }; }