Ejemplo n.º 1
0
        private void RemoveClick()
        {
            if (DisplayPackage.IsBuiltIn)
            {
                var roots = Collection.GetDependents(DisplayPackage).ToList();
                if (roots.Any())
                {
                    if (roots.Count > MaxDependentList)
                    {
                        Debug.Log(GetDependentMessage(roots, int.MaxValue));
                    }

                    var message = GetDependentMessage(roots);
                    EditorUtility.DisplayDialog("Cannot Disable Built-In Package", message, "Ok");

                    return;
                }
            }

            var result = 1;    // Cancel

            if (!PackageManagerPrefs.SkipRemoveConfirmation)
            {
                result = EditorUtility.DisplayDialogComplex("Removing Package",
                                                            "Are you sure you wanted to remove this package?",
                                                            "Remove", "Cancel", "Remove and do not ask again");
            }
            else
            {
                result = 0;
            }

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

            // Do not ask again
            if (result == 2)
            {
                PackageManagerPrefs.SkipRemoveConfirmation = true;
            }

            // Remove
            DetailError.ClearError();
            package.Remove();
            RefreshRemoveButton();
            RefreshAddButton();
        }
Ejemplo n.º 2
0
        private void RemoveClick()
        {
            if (DisplayPackage.IsBuiltIn)
            {
                var roots = Collection.GetDependents(DisplayPackage).ToList();
                if (roots.Any())
                {
                    if (roots.Count > MaxDependentList)
                    {
                        Debug.Log(GetDependentMessage(roots, int.MaxValue));
                    }

                    var message = GetDependentMessage(roots);
                    EditorUtility.DisplayDialog("Cannot Disable Built-In Package", message, "Ok");

                    return;
                }
            }

            if (DisplayPackage.IsInDevelopment)
            {
                if (!EditorUtility.DisplayDialog("Unity Package Manager", "You will loose all your changes (if any) if you delete a package in development. Are you sure?", "Yes", "No"))
                {
                    return;
                }

                RefreshRemoveButton();
                RefreshAddButton();

                Directory.Delete(DisplayPackage.Info.resolvedPath, true);
                AssetDatabase.Refresh();
                EditorApplication.delayCall += () =>
                {
                    if (Collection.Filter == PackageFilter.InDevelopment)
                    {
                        var otherInDev = Collection.listPackages.Any(info => info.IsInDevelopment && info.Name != package.Name);
                        PackageManagerWindow.SelectPackageAndFilter(DisplayPackage.VersionId, otherInDev ? PackageFilter.InDevelopment : PackageFilter.Local, true);
                    }
                    else
                    {
                        PackageManagerWindow.SelectPackageAndFilter(DisplayPackage.VersionId, null, true);
                    }
                };

                return;
            }

            var result = 0;

            if (DisplayPackage.IsBuiltIn)
            {
                if (!PackageManagerPrefs.SkipDisableConfirmation)
                {
                    result = EditorUtility.DisplayDialogComplex("Disable Built-In Package",
                                                                "Are you sure you want to disable this built-in package?",
                                                                "Disable", "Cancel", "Never ask");
                }
            }
            else
            {
                if (!PackageManagerPrefs.SkipRemoveConfirmation)
                {
                    result = EditorUtility.DisplayDialogComplex("Removing Package",
                                                                "Are you sure you want to remove this package?",
                                                                "Remove", "Cancel", "Never ask");
                }
            }

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

            // Do not ask again
            if (result == 2)
            {
                if (DisplayPackage.IsBuiltIn)
                {
                    PackageManagerPrefs.SkipDisableConfirmation = true;
                }
                else
                {
                    PackageManagerPrefs.SkipRemoveConfirmation = true;
                }
            }

            // Remove
            DetailError.ClearError();
            package.Remove();
            RefreshRemoveButton();
            RefreshAddButton();
        }