Beispiel #1
0
        protected override void DrawSettingsBody()
        {
            if (UIHelpers.ImageButton("Manage Filters...", CSIcons.Gear))
            {
                CleanerFiltersWindow.Create();
            }

            using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground))
            {
                GUILayout.Space(5);
                EditorGUI.BeginChangeCheck();
                MaintainerSettings.Cleaner.useTrashBin = EditorGUILayout.ToggleLeft(new GUIContent("Use Trash Bin (drops clean speed)", "All deleted items will be moved to Trash if selected. Otherwise items will be deleted permanently.\nPlease note: dramatically reduces removal performance when enabled!"), MaintainerSettings.Cleaner.useTrashBin);
                if (EditorGUI.EndChangeCheck())
                {
                    if (!MaintainerSettings.Cleaner.useTrashBin && !MaintainerPersonalSettings.Cleaner.trashBinWarningShown)
                    {
                        EditorUtility.DisplayDialog(ProjectCleaner.ModuleName, "Please note, in case of not using Trash Bin, files will be removed permanently, without possibility to recover them in case of mistake.\nAuthor is not responsible for any damage made due to the module usage!\nThis message shows only once.", "Dismiss");
                        MaintainerPersonalSettings.Cleaner.trashBinWarningShown = true;
                    }
                }

                MaintainerSettings.Cleaner.rescanAfterContextIgnore = EditorGUILayout.ToggleLeft(new GUIContent("Rescan after new context ignore", "Project scan will be automatically started after you add any new ignore from the results more button context menu.\nProject scan is necessary to automatically exclude all referenced items from garbage too."), MaintainerSettings.Cleaner.rescanAfterContextIgnore);

                UIHelpers.Separator();
                GUILayout.Space(5);
                GUILayout.Label("<b><size=12>Search for:</size></b>", UIHelpers.richLabel);
                using (new GUILayout.HorizontalScope())
                {
                    MaintainerSettings.Cleaner.findUnreferencedAssets = EditorGUILayout.ToggleLeft(new GUIContent("Unused assets", "Search for unreferenced assets in project."), MaintainerSettings.Cleaner.findUnreferencedAssets, GUILayout.Width(100));
                }
                using (new GUILayout.HorizontalScope())
                {
                    MaintainerSettings.Cleaner.findEmptyFolders = EditorGUILayout.ToggleLeft(new GUIContent("Empty folders", "Search for all empty folders in project."), MaintainerSettings.Cleaner.findEmptyFolders, GUILayout.Width(100));
                    GUI.enabled = MaintainerSettings.Cleaner.findEmptyFolders;
                    EditorGUI.BeginChangeCheck();
                    MaintainerSettings.Cleaner.findEmptyFoldersAutomatically = EditorGUILayout.ToggleLeft(new GUIContent("Autoclean", "Perform empty folders clean automatically on every scripts reload."), MaintainerSettings.Cleaner.findEmptyFoldersAutomatically, GUILayout.Width(100));
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (MaintainerSettings.Cleaner.findEmptyFoldersAutomatically)
                        {
                            EditorUtility.DisplayDialog(ProjectCleaner.ModuleName, "In case you're having thousands of folders in your project this may hang Unity for few additional secs on every scripts reload.\n" + Maintainer.DataLossWarning, "Understood");
                        }
                    }
                    GUI.enabled = true;
                }

                GUILayout.Space(5);

                if (UIHelpers.ImageButton("Reset", "Resets settings to defaults.", CSIcons.Restore))
                {
                    MaintainerSettings.Cleaner.Reset();
                }
            }
        }
Beispiel #2
0
        protected override void DrawSettingsBody()
        {
            using (layout.Vertical(UIHelpers.panelWithBackground))
            {
                GUILayout.Space(5);

                if (UIHelpers.ImageButton("Manage Filters...", CSIcons.Gear))
                {
                    CleanerFiltersWindow.Create();
                }

                GUILayout.Space(5);

                MaintainerSettings.Cleaner.useTrashBin = EditorGUILayout.ToggleLeft(new GUIContent("Use Trash Bin", "All deleted items will be moved to Trash if selected. Otherwise items will be deleted permanently."), MaintainerSettings.Cleaner.useTrashBin);
                UIHelpers.Separator();
                GUILayout.Space(5);
                GUILayout.Label("<b><size=12>Search for:</size></b>", UIHelpers.richLabel);
                MaintainerSettings.Cleaner.findUnusedAssets = EditorGUILayout.ToggleLeft(new GUIContent("Unused assets", "Search for unused assets in project."), MaintainerSettings.Cleaner.findUnusedAssets, GUILayout.Width(100));
                using (layout.Horizontal())
                {
                    MaintainerSettings.Cleaner.findEmptyFolders = EditorGUILayout.ToggleLeft(new GUIContent("Empty folders", "Search for all empty folders in project."), MaintainerSettings.Cleaner.findEmptyFolders, GUILayout.Width(100));
                    GUI.enabled = MaintainerSettings.Cleaner.findEmptyFolders;

                    EditorGUI.BeginChangeCheck();
                    MaintainerSettings.Cleaner.findEmptyFoldersAutomatically = EditorGUILayout.ToggleLeft(new GUIContent("Autoclean", "Perform empty folders clean automatically on every scripts reload."), MaintainerSettings.Cleaner.findEmptyFoldersAutomatically, GUILayout.Width(100));
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (MaintainerSettings.Cleaner.findEmptyFoldersAutomatically)
                        {
                            EditorUtility.DisplayDialog(ProjectCleaner.MODULE_NAME, "In case you're having thousands of folders in your project this may hang Unity for few additional secs on every scripts reload.\n" + Maintainer.DATA_LOSS_WARNING, "Understood");
                        }
                    }
                    GUI.enabled = true;
                }

                GUILayout.Space(5);

                if (UIHelpers.ImageButton("Reset", "Resets settings to defaults.", CSIcons.Restore))
                {
                    MaintainerSettings.Cleaner.Reset();
                }
            }
        }
Beispiel #3
0
        private void DrawMoreButton(AssetRecord assetRecord)
        {
            if (UIHelpers.RecordButton(assetRecord, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                GenericMenu menu = new GenericMenu();
                if (!string.IsNullOrEmpty(assetRecord.path))
                {
                    menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                    {
                        if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, assetRecord.assetDatabasePath))
                        {
                            MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                        }
                    });

                    DirectoryInfo dir = Directory.GetParent(assetRecord.assetDatabasePath);
                    if (dir.Name != "Assets")
                    {
                        menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                        {
                            if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, dir.ToString()))
                            {
                                MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                CleanerFiltersWindow.Refresh();
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                            }
                        });
                    }
                }
                menu.ShowAsContext();
            }
        }
Beispiel #4
0
        private void DrawMoreButton(AssetRecord assetRecord)
        {
            if (UIHelpers.RecordButton(assetRecord, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                var menu = new GenericMenu();
                if (!string.IsNullOrEmpty(assetRecord.path))
                {
                    menu.AddItem(new GUIContent("Ignore/Full Path"), false, () =>
                    {
                        if (!CSFilterTools.IsValueMatchesAnyFilter(assetRecord.assetDatabasePath, MaintainerSettings.Cleaner.pathIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(assetRecord.assetDatabasePath, FilterKind.Path);
                            ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                            CleanerFiltersWindow.Refresh();

                            if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                            {
                                StartSearch();
                            }
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });

                    var dir = Directory.GetParent(assetRecord.assetDatabasePath);
                    if (!CSPathTools.IsAssetsRootPath(dir.FullName))
                    {
                        menu.AddItem(new GUIContent("Ignore/Parent Folder"), false, () =>
                        {
                            var dirPath = CSPathTools.EnforceSlashes(dir.ToString());

                            if (!CSFilterTools.IsValueMatchesAnyFilter(dirPath, MaintainerSettings.Cleaner.pathIgnoresFilters))
                            {
                                var newFilter = FilterItem.Create(dirPath, FilterKind.Directory);
                                ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                                MaintainerWindow.ShowNotification("Ignore added: " + dirPath);
                                CleanerFiltersWindow.Refresh();

                                if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                                {
                                    StartSearch();
                                }
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Already added to the ignores!");
                            }
                        });
                    }

                    var extension = Path.GetExtension(assetRecord.path);
                    if (!string.IsNullOrEmpty(extension))
                    {
                        menu.AddItem(new GUIContent("Ignore/\"" + extension + "\" Extension"), false, () =>
                        {
                            if (!CSFilterTools.IsValueMatchesAnyFilterOfKind(extension, MaintainerSettings.Cleaner.pathIgnoresFilters, FilterKind.Extension))
                            {
                                var newFilter = FilterItem.Create(extension, FilterKind.Extension, true);
                                ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                                MaintainerWindow.ShowNotification("Ignore added: " + extension);
                                CleanerFiltersWindow.Refresh();

                                if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                                {
                                    StartSearch();
                                }
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Already added to the ignores!");
                            }
                        });
                    }
                }
                menu.ShowAsContext();
            }
        }
Beispiel #5
0
        private void DrawMoreButton(AssetIssueRecord record)
        {
            if (!UIHelpers.RecordButton(record, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                return;
            }

            var menu = new GenericMenu();

            if (!string.IsNullOrEmpty(record.Path))
            {
                menu.AddItem(new GUIContent("Ignore/Full Path"), false, () =>
                {
                    if (!CSFilterTools.IsValueMatchesAnyFilter(record.Path, ProjectSettings.Issues.pathIgnoresFilters))
                    {
                        var newFilter = FilterItem.Create(record.Path, FilterKind.Path);
                        ArrayUtility.Add(ref ProjectSettings.Issues.pathIgnoresFilters, newFilter);

                        ApplyNewIgnoreFilter(newFilter);

                        MaintainerWindow.ShowNotification("Ignore added: " + record.Path);
                        CleanerFiltersWindow.Refresh();
                    }
                    else
                    {
                        MaintainerWindow.ShowNotification("Already added to the ignores!");
                    }
                });

                var dir = Directory.GetParent(record.Path);
                if (!CSPathTools.IsAssetsRootPath(dir.FullName))
                {
                    menu.AddItem(new GUIContent("Ignore/Parent Folder"), false, () =>
                    {
                        var dirPath = CSPathTools.EnforceSlashes(dir.ToString());

                        if (!CSFilterTools.IsValueMatchesAnyFilter(dirPath, ProjectSettings.Issues.pathIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(dirPath, FilterKind.Directory);
                            ArrayUtility.Add(ref ProjectSettings.Issues.pathIgnoresFilters, newFilter);

                            ApplyNewIgnoreFilter(newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + dirPath);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });
                }
            }

            var objectIssue = record as GameObjectIssueRecord;

            if (objectIssue != null)
            {
                if (!string.IsNullOrEmpty(objectIssue.componentName))
                {
                    menu.AddItem(new GUIContent("Ignore/\"" + objectIssue.componentName + "\" Component"), false, () =>
                    {
                        if (!CSFilterTools.IsValueMatchesAnyFilter(objectIssue.componentName, ProjectSettings.Issues.componentIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(objectIssue.componentName, FilterKind.Type);
                            ArrayUtility.Add(ref ProjectSettings.Issues.componentIgnoresFilters, newFilter);

                            ApplyNewIgnoreFilter(newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.componentName);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });
                }
            }


            menu.ShowAsContext();
        }
Beispiel #6
0
        protected override void DrawLeftColumnBody()
        {
            using (new GUILayout.VerticalScope(/*UIHelpers.panelWithBackground*/))
            {
#if  UNITY_2019_3_OR_NEWER
                if (!BuildReportAnalyzer.IsReportExists())
                {
                    EditorGUILayout.HelpBox("No build data found: search will be more accurate if you'll make a build", MessageType.Warning);
                }
#endif

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);
                    using (new GUILayout.VerticalScope(/*UIHelpers.panelWithButtonBackground*/))
                    {
                        GUILayout.Label("<b><size=16>Settings</size></b>", UIHelpers.richLabel);
                        UIHelpers.Separator();
                    }
                    GUILayout.Space(10);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);

                    using (new GUILayout.VerticalScope())
                    {
                        GUILayout.Space(10);

                        if (UIHelpers.ImageButton("Filters (" + ProjectSettings.Cleaner.GetFiltersCount() + ")", CSIcons.Filter))
                        {
                            CleanerFiltersWindow.Create();
                        }

                        GUILayout.Space(10);

                        EditorGUI.BeginChangeCheck();
                        ProjectSettings.Cleaner.useTrashBin = EditorGUILayout.ToggleLeft(new GUIContent("Use Trash Bin (slows cleanup)", "All deleted items will be moved to Trash if selected. Otherwise items will be deleted permanently.\nPlease note: dramatically reduces removal performance when enabled!"), ProjectSettings.Cleaner.useTrashBin);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (!ProjectSettings.Cleaner.useTrashBin && !UserSettings.Cleaner.trashBinWarningShown)
                            {
                                EditorUtility.DisplayDialog(ProjectCleaner.ModuleName, "Please note, in case of not using Trash Bin, files will be removed permanently, without possibility to recover them in case of mistake.\nAuthor is not responsible for any damage made due to the module usage!\nThis message shows only once.", "Dismiss");
                                UserSettings.Cleaner.trashBinWarningShown = true;
                            }
                        }

                        ProjectSettings.Cleaner.rescanAfterContextIgnore = EditorGUILayout.ToggleLeft(new GUIContent("Rescan after new context ignore", "Project scan will be automatically started after you add any new ignore from the results more button context menu.\nProject scan is necessary to automatically exclude all referenced items from garbage too."), ProjectSettings.Cleaner.rescanAfterContextIgnore);

                        GUILayout.Space(5);
                        GUILayout.Label("<b><size=12>Search for:</size></b>", UIHelpers.richLabel);
                        UIHelpers.Separator();
                        using (new GUILayout.HorizontalScope())
                        {
                            ProjectSettings.Cleaner.findUnreferencedAssets = EditorGUILayout.ToggleLeft(new GUIContent("Unused assets", "Search for unreferenced assets in project."), ProjectSettings.Cleaner.findUnreferencedAssets, GUILayout.Width(105));
                        }
                        using (new GUILayout.HorizontalScope())
                        {
                            ProjectSettings.Cleaner.findEmptyFolders = EditorGUILayout.ToggleLeft(new GUIContent("Empty folders", "Search for all empty folders in project."), ProjectSettings.Cleaner.findEmptyFolders, GUILayout.Width(100));
                            GUI.enabled = ProjectSettings.Cleaner.findEmptyFolders;
                            EditorGUI.BeginChangeCheck();
                            ProjectSettings.Cleaner.findEmptyFoldersAutomatically = EditorGUILayout.ToggleLeft(new GUIContent("Autoclean", "Perform empty folders clean automatically on every scripts reload."), ProjectSettings.Cleaner.findEmptyFoldersAutomatically, GUILayout.Width(100));
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (ProjectSettings.Cleaner.findEmptyFoldersAutomatically)
                                {
                                    EditorUtility.DisplayDialog(ProjectCleaner.ModuleName, "In case you're having thousands of folders in your project this may hang Unity for few additional secs on every scripts reload.\n" + Maintainer.DataLossWarning, "Understood");
                                }
                            }
                            GUI.enabled = true;
                        }

                        GUILayout.Space(10);

                        if (UIHelpers.ImageButton("Reset", "Resets settings to defaults.", CSIcons.Restore))
                        {
                            ProjectSettings.Cleaner.Reset();
                        }

                        GUILayout.Space(10);
                    }

                    GUILayout.Space(10);
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(10);
                using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
                {
                    GUILayout.Label("<b><size=16>Stats</size></b>", UIHelpers.richLabel);
                    UIHelpers.Separator();
                    GUILayout.Space(10);
                    DrawStatsBody();
                }
                GUILayout.Space(10);
            }
        }