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!"); } }
public static MaintainerWindow Create() { windowInstance = GetWindow <MaintainerWindow>(false, "Maintainer", true); windowInstance.titleContent = new GUIContent(" Maintainer", CSIcons.Maintainer); windowInstance.Focus(); return(windowInstance); }
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!"); } }
public static MaintainerWindow Create() { MaintainerWindow window = GetWindow <MaintainerWindow>("Maintainer"); window.Init(); return(window); }
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(); } } } }
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); }
public static MaintainerWindow Create(MaintainerTab tab) { windowInstance = Create(); if (windowInstance.currentTab != tab) { windowInstance.currentTab = MaintainerPersonalSettings.Instance.selectedTab = tab; } windowInstance.Refresh(true); return(windowInstance); }
private static MaintainerWindow Create(MaintainerTab tab) { windowInstance = Create(); if (windowInstance.currentTab != tab) { windowInstance.currentTab = UserSettings.Instance.selectedTab = tab; } windowInstance.Refresh(true); return(windowInstance); }
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!"); } } }
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; }
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 }; } }
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; } } } }
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"); } } }
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(); }
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"); } } }
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; }
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(); } }
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(); }; }
public CleanerTab(MaintainerWindow maintainerWindow) : base(maintainerWindow) { }
private void OnEnable() { hideFlags = HideFlags.HideAndDontSave; windowInstance = this; }
protected TwoColumnsTab(MaintainerWindow window) : base(window) { }
public ProjectReferencesTab(MaintainerWindow window) : base(window) { treePanel = new ProjectReferencesTreePanel(window); }
public ReferencesTab(MaintainerWindow window) { this.window = window; treePanel = new ReferencesTreePanel(); }
internal ExactReferencesListPanel(MaintainerWindow window) { }
public AboutTab(MaintainerWindow window) : base(window) { }
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!"); } } } } }
/* virtual methods */ protected RecordsTab(MaintainerWindow window) { this.window = window; }
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(); } }
public AboutTab(MaintainerWindow window) { this.window = window; }