コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
 protected override bool TriggerAction(IList <IPackageVersion> versions)
 {
     m_PageManager.SetPackagesUserUnlockedState(versions.Select(v => v.packageUniqueId), true);
     PackageManagerWindowAnalytics.SendEvent("unlock", packageIds: versions.Select(v => v.packageUniqueId));
     return(true);
 }