Ejemplo n.º 1
0
 protected void DrawCopyButton(T record)
 {
     if (UIHelpers.RecordButton(record, "Copy", "Copies record text to the clipboard.", CSIcons.Copy))
     {
         EditorGUIUtility.systemCopyBuffer = record.ToString(true);
         MaintainerWindow.ShowNotification("Record copied to clipboard!");
     }
 }
Ejemplo n.º 2
0
        public static MaintainerWindow Create()
        {
            windowInstance = GetWindow <MaintainerWindow>(false, "Maintainer", true);
            windowInstance.titleContent = new GUIContent(" Maintainer", CSIcons.Maintainer);
            windowInstance.Focus();

            return(windowInstance);
        }
Ejemplo n.º 3
0
 protected void DrawCopyReportButton()
 {
     if (UIHelpers.ImageButton("Copy report to clipboard", CSIcons.Copy))
     {
         EditorGUIUtility.systemCopyBuffer = ReportsBuilder.GenerateReport(GetModuleName(), filteredRecords, GetReportHeader(), GetReportFooter());
         MaintainerWindow.ShowNotification("Report copied to clipboard!");
     }
 }
Ejemplo n.º 4
0
        public static MaintainerWindow Create()
        {
            MaintainerWindow window = GetWindow <MaintainerWindow>("Maintainer");

            window.Init();

            return(window);
        }
Ejemplo n.º 5
0
        private void DrawRecordButtons(RecordBase record)
        {
            using (UIHelpers.Horizontal(UIHelpers.panelWithBackground))
            {
                AddShowButtonIfPossible(record);

                AssetRecord assetRecord = record as AssetRecord;
                if (assetRecord != null)
                {
                    if (GUILayout.Button(new GUIContent("Reveal", "Reveals item in system default File Manager like Explorer on Windows or Finder on Mac."), UIHelpers.recordButton))
                    {
                        EditorUtility.RevealInFinder(assetRecord.path);
                    }

                    if (GUILayout.Button("More ...", UIHelpers.recordButton))
                    {
                        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))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                                    CleanerIgnoresWindow.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()))
                                    {
                                        MaintainerSettings.Save();
                                        MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                        CleanerIgnoresWindow.Refresh();
                                    }
                                    else
                                    {
                                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                    }
                                });
                            }
                        }
                        menu.ShowAsContext();
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void OnEnable()
        {
            hideFlags      = HideFlags.HideAndDontSave;
            windowInstance = this;

#if UNITY_5_1_PLUS
            titleContent = new GUIContent(" Maintainer", CSIcons.Maintainer);
#else
            title = "Maintainer";
#endif
        }
        public static MaintainerWindow Create()
        {
            MaintainerWindow window = GetWindow <MaintainerWindow>("Maintainer");

            window.minSize = new Vector2(640f, 480f);
            window.Focus();
            currentTab = MaintainerSettings.Instance.selectedTabIndex;

            IssuesTab.Refresh();

            return(window);
        }
Ejemplo n.º 8
0
        public static MaintainerWindow Create(MaintainerTab tab)
        {
            windowInstance = Create();

            if (windowInstance.currentTab != tab)
            {
                windowInstance.currentTab = MaintainerPersonalSettings.Instance.selectedTab = tab;
            }
            windowInstance.Refresh(true);

            return(windowInstance);
        }
Ejemplo n.º 9
0
        private static MaintainerWindow Create(MaintainerTab tab)
        {
            windowInstance = Create();

            if (windowInstance.currentTab != tab)
            {
                windowInstance.currentTab = UserSettings.Instance.selectedTab = tab;
            }
            windowInstance.Refresh(true);

            return(windowInstance);
        }
Ejemplo n.º 10
0
 protected void DrawExportReportButton()
 {
     if (UIHelpers.ImageButton("Export report...", CSIcons.Export))
     {
         var filePath = EditorUtility.SaveFilePanel("Save " + GetModuleName() + " report", "", "Maintainer " + GetReportFileNamePart() + "Report.txt", "txt");
         if (!string.IsNullOrEmpty(filePath))
         {
             var sr = File.CreateText(filePath);
             sr.Write(ReportsBuilder.GenerateReport(GetModuleName(), filteredRecords, GetReportHeader(), GetReportFooter()));
             sr.Close();
             MaintainerWindow.ShowNotification("Report saved!");
         }
     }
 }
Ejemplo n.º 11
0
        private void DrawFixButton(IssueRecord record, int recordIndex)
        {
            GUI.enabled = record.IsFixable;

            var label = "Fix";
            var hint  = "Automatically fixes issue (not available for this issue yet).";

            if (record.Kind == IssueKind.MissingComponent)
            {
                label = "Remove";
                hint  = "Removes missing component.";
            }
            else if (record.Kind == IssueKind.MissingReference)
            {
                label = "Reset";
                hint  = "Resets missing reference to default None value.";
            }

            if (UIHelpers.RecordButton(record, label, hint, CSIcons.AutoFix))
            {
                var fixResult = record.Fix(false);
                if (fixResult != null && fixResult.Success)
                {
                    DeleteRecords(new[] { recordIndex });

                    var notificationExtra = "";

                    if (record.Location == RecordLocation.Prefab || record.Location == RecordLocation.Asset)
                    {
                        AssetDatabase.SaveAssets();
                    }

                    MaintainerWindow.ShowNotification("Issue successfully fixed!" + notificationExtra);
                }
                else
                {
                    var notificationText = "Could not fix the issue!";
                    if (fixResult != null && !string.IsNullOrEmpty(fixResult.ErrorText))
                    {
                        notificationText = fixResult.ErrorText;
                    }
                    MaintainerWindow.ShowNotification(notificationText);
                }
            }

            GUI.enabled = true;
        }
Ejemplo n.º 12
0
        public ReferencesTab(MaintainerWindow window) : base(window)
        {
            if (projectTab == null)
            {
                projectTab = new ProjectReferencesTab(window);
            }

            if (hierarchyTab == null)
            {
                hierarchyTab = new HierarchyReferencesTab(window);
            }

            if (tabsCaptions == null)
            {
                tabsCaptions = new[] { projectTab.Caption, hierarchyTab.Caption };
            }
        }
Ejemplo n.º 13
0
        protected override void DrawSearchBody()
        {
            if (GUILayout.Button("Find issues!"))
            {
                startSearch = true;
            }
            GUILayout.Space(10);

            if (records == null || records.Length == 0)
            {
                GUILayout.Label("No issues");
            }
            else
            {
                ShowCollectionPages();

                GUILayout.Space(5);

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Copy report to clipboard"))
                    {
                        EditorGUIUtility.systemCopyBuffer = ReportsBuilder.GenerateReport(IssuesFinder.MODULE_NAME, records);
                        MaintainerWindow.ShowNotification("Report copied to clipboard!");
                    }

                    if (GUILayout.Button("Export report..."))
                    {
                        string filePath = EditorUtility.SaveFilePanel("Save Issues Finder report", "", "MaintainerIssuesReport.txt", "txt");
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            StreamWriter sr = File.CreateText(filePath);
                            sr.Write(ReportsBuilder.GenerateReport(IssuesFinder.MODULE_NAME, records));
                            sr.Close();
                            MaintainerWindow.ShowNotification("Report saved!");
                        }
                    }

                    if (GUILayout.Button("Clear results"))
                    {
                        records = null;
                        SearchResultsStorage.IssuesSearchResults = null;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private static void ShowItem(ReferencesTreeViewItem <T> item)
        {
            var assetPath = item.data.assetPath;

            if (item.data.assetSettingsKind == AssetSettingsKind.NotSettings)
            {
                if (!CSSelectionTools.RevealAndSelectFileAsset(assetPath))
                {
                    MaintainerWindow.ShowNotification("Can't show it properly");
                }
            }
            else
            {
                if (!CSEditorTools.RevealInSettings(item.data.assetSettingsKind, assetPath))
                {
                    MaintainerWindow.ShowNotification("Can't show it properly");
                }
            }
        }
Ejemplo n.º 15
0
        public static void Draw(MaintainerWindow parentWindow)
        {
            GUILayout.Space(30);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();
            GUILayout.Space(5);

            Texture2D logo;

            if (EditorGUIUtility.isProSkin)
            {
                logo = GetLogoTexture(LOGO_DARK_NAME);
            }
            else
            {
                logo = GetLogoTexture(LOGO_LIGHT_NAME);
            }

            if (logo != null)
            {
                Rect logoRect = EditorGUILayout.GetControlRect(GUILayout.Width(logo.width), GUILayout.Height(logo.height));
                GUI.DrawTexture(logoRect, logo);
            }

            GUILayout.Space(10);
            GUILayout.Label("<size=14><b>Maintainer ver. " + Maintainer.VERSION + "</b></size>", UIHelpers.centeredLabel);
            GUILayout.Label("Developed by Dmitriy Yukhanov", UIHelpers.centeredLabel);
            GUILayout.Space(10);
            if (GUILayout.Button("Homepage"))
            {
                Application.OpenURL(HOMEPAGE);
            }
            if (GUILayout.Button("Support contacts"))
            {
                Application.OpenURL(SUPPORT_LINK);
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 16
0
        protected override void ShowItem(TreeViewItem clickedItem)
        {
            var item      = (ProjectReferencesTreeViewItem <T>)clickedItem;
            var assetPath = item.data.assetPath;

            if (item.data.assetSettingsKind == AssetSettingsKind.NotSettings)
            {
                if (!CSSelectionTools.RevealAndSelectFileAsset(assetPath))
                {
                    MaintainerWindow.ShowNotification("Can't show it properly");
                }
            }
            else
            {
                if (!CSEditorTools.RevealInSettings(item.data.assetSettingsKind, assetPath))
                {
                    MaintainerWindow.ShowNotification("Can't show it properly");
                }
            }
        }
Ejemplo n.º 17
0
        private void DrawFixButton(IssueRecord record, int recordIndex)
        {
            GUI.enabled = record.CanBeFixed();

            string label = "Fix";
            string hint  = "Automatically fixes issue (not available for this issue yet).";

            if (record.type == RecordType.MissingComponent)
            {
                label = "Remove";
                hint  = "Removes missing component.";
            }
            else if (record.type == RecordType.MissingReference)
            {
                label = "Reset";
                hint  = "Resets missing reference to default None value.";
            }

            if (UIHelpers.RecordButton(record, label, hint, CSIcons.AutoFix))
            {
                if (record.Fix(false))
                {
                    HideRecord(recordIndex);

                    string notificationExtra = "";

                    if (record.location == RecordLocation.Prefab || record.location == RecordLocation.Asset)
                    {
                        AssetDatabase.SaveAssets();
                    }
                    else if (record.location == RecordLocation.Scene)
                    {
                        notificationExtra = "\nDon't forget to save the scene!";
                    }

                    MaintainerWindow.ShowNotification("Issue successfully fixed!" + notificationExtra);
                }
            }

            GUI.enabled = true;
        }
Ejemplo n.º 18
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();
            }
        }
Ejemplo n.º 19
0
        protected void SelectRowInternal(MaintainerTreeViewItem <T> rowLocal)
        {
            EditorApplication.delayCall += () =>
            {
                var id = rowLocal.id;
                SetExpanded(id, true);

                var childId = -1;
                if (rowLocal.data.HasChildren && rowLocal.data.Children.Count > 0)
                {
                    var child = rowLocal.data.Children[0];
                    childId = child.id;
                }

                FrameItem(childId > -1 ? childId : id);

                SetSelection(new List <int> {
                    id
                });
                SetFocusAndEnsureSelectedItem();

                MaintainerWindow.RepaintInstance();
            };
        }
Ejemplo n.º 20
0
 public CleanerTab(MaintainerWindow maintainerWindow) : base(maintainerWindow)
 {
 }
Ejemplo n.º 21
0
 private void OnEnable()
 {
     hideFlags      = HideFlags.HideAndDontSave;
     windowInstance = this;
 }
Ejemplo n.º 22
0
 protected TwoColumnsTab(MaintainerWindow window) : base(window)
 {
 }
Ejemplo n.º 23
0
 public ProjectReferencesTab(MaintainerWindow window) : base(window)
 {
     treePanel = new ProjectReferencesTreePanel(window);
 }
Ejemplo n.º 24
0
 public ReferencesTab(MaintainerWindow window)
 {
     this.window = window;
     treePanel   = new ReferencesTreePanel();
 }
Ejemplo n.º 25
0
 internal ExactReferencesListPanel(MaintainerWindow window)
 {
 }
Ejemplo n.º 26
0
 public AboutTab(MaintainerWindow window) : base(window)
 {
 }
Ejemplo n.º 27
0
        protected override void DrawSearchBody()
        {
            //GUILayout.BeginHorizontal();
            if (GUILayout.Button("1. Find garbage!"))
            {
                startSearch = true;
            }

            if (GUILayout.Button("2. Clean selected items!"))
            {
                startClean = true;
            }
            //GUILayout.EndHorizontal();
            GUILayout.Space(10);

            if (records == null || records.Length == 0)
            {
                GUILayout.Label("No garbage");
            }
            else
            {
                ShowCollectionPages();

                GUILayout.Space(5);

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Select all"))
                    {
                        foreach (CleanerRecord record in records.OfType <CleanerRecord>())
                        {
                            record.selected = true;
                        }
                        SearchResultsStorage.Save();
                    }

                    if (GUILayout.Button("Select none"))
                    {
                        foreach (CleanerRecord record in records.OfType <CleanerRecord>())
                        {
                            record.selected = false;
                        }
                        SearchResultsStorage.Save();
                    }

                    if (GUILayout.Button("Clear results"))
                    {
                        records = null;
                        SearchResultsStorage.CleanerSearchResults = null;
                    }
                }

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Copy report to clipboard"))
                    {
                        EditorGUIUtility.systemCopyBuffer = ReportsBuilder.GenerateReport(ProjectCleaner.MODULE_NAME, records);
                        MaintainerWindow.ShowNotification("Report copied to clipboard!");
                    }
                    if (GUILayout.Button("Export report..."))
                    {
                        string filePath = EditorUtility.SaveFilePanel("Save " + ProjectCleaner.MODULE_NAME + " report", "", "MaintainerCleanerReport.txt", "txt");
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            StreamWriter sr = File.CreateText(filePath);
                            sr.Write(ReportsBuilder.GenerateReport(ProjectCleaner.MODULE_NAME, records));
                            sr.Close();
                            MaintainerWindow.ShowNotification("Report saved!");
                        }
                    }
                }
            }
        }
Ejemplo n.º 28
0
        /* virtual methods */

        protected RecordsTab(MaintainerWindow window)
        {
            this.window = window;
        }
Ejemplo n.º 29
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();
            }
        }
Ejemplo n.º 30
0
 public AboutTab(MaintainerWindow window)
 {
     this.window = window;
 }