void DrawActions() { if (!activeView.desc.showActions) { return; } var table = activeView.table; EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true)); m_Preferences.actions = Utility.BoldFoldout(m_Preferences.actions, Contents.ActionsFoldout); if (m_Preferences.actions) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUI.enabled = activeView.desc.showMuteOptions; EditorGUILayout.LabelField("Selected :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); if (GUILayout.Button(Contents.MuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = table.GetSelectedItems(); foreach (var item in selectedItems) { SetRuleForItem(item, Rule.Severity.None); } if (!m_Preferences.mutedIssues) { table.SetSelection(new List <int>()); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary(ProjectAuditorAnalytics.UIButton.Mute, analytic, table.GetSelectedItems()); } if (GUILayout.Button(Contents.UnmuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = table.GetSelectedItems(); foreach (var item in selectedItems) { ClearRulesForItem(item); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary( ProjectAuditorAnalytics.UIButton.Unmute, analytic, table.GetSelectedItems()); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); }
void RefreshDisplay() { if (!IsAnalysisValid()) { return; } if (m_AnalysisState == AnalysisState.Completed) { UpdateAssemblyNames(); UpdateAssemblySelection(); m_AnalysisState = AnalysisState.Valid; if (m_LoadButtonAnalytic != null) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Load, m_LoadButtonAnalytic); } if (m_AnalyzeButtonAnalytic != null) { ProjectAuditorAnalytics.SendUIButtonEventWithAnalyzeSummary(ProjectAuditorAnalytics.UIButton.Analyze, m_AnalyzeButtonAnalytic, m_ProjectReport); } } activeView.Refresh(); }
void OnEnable() { ProjectAuditorAnalytics.EnableAnalytics(); m_ProjectAuditor = new ProjectAuditor(); UpdateAssemblySelection(); if (m_AreaSelection == null) { m_AreaSelection = new TreeViewSelection(); if (!string.IsNullOrEmpty(m_AreaSelectionSummary)) { if (m_AreaSelectionSummary == "All") { m_AreaSelection.SetAll(AreaNames); } else if (m_AreaSelectionSummary != "None") { var areas = m_AreaSelectionSummary.Split(new[] { ", " }, StringSplitOptions.None); foreach (var area in areas) { m_AreaSelection.selection.Add(area); } } } else { m_AreaSelection.SetAll(AreaNames); } } m_ModeNames = m_AnalysisViewDescriptors.Select(m => m.name).ToArray(); if (m_TextFilter == null) { m_TextFilter = new TextFilter(); } m_AnalysisViews.Clear(); foreach (var desc in m_AnalysisViewDescriptors) { var view = new AnalysisView(); view.CreateTable(desc, m_ProjectAuditor.config, m_Preferences, this); if (m_AnalysisState == AnalysisState.Valid) { view.AddIssues(m_ProjectReport.GetIssues(view.desc.category)); } m_AnalysisViews.Add(view); } RefreshDisplay(); }
void ApplySelection() { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ProjectAuditorWindow.SetAreaSelection(m_AreaTable.GetTreeViewSelection()); var payload = new Dictionary <string, string>(); payload["areas"] = m_ProjectAuditorWindow.GetSelectedAreasSummary(); ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.AreaSelectApply, analytic, payload); }
void Save() { var path = EditorUtility.SaveFilePanel("Save report to json file", m_SaveLoadDirectory, "project-auditor-report.json", "json"); if (path.Length != 0) { m_ProjectReport.Save(path); m_SaveLoadDirectory = Path.GetDirectoryName(path); EditorUtility.RevealInFinder(path); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Save, ProjectAuditorAnalytics.BeginAnalytic()); } }
// stephenm TODO - if AssemblySelectionWindow and AreaSelectionWindow end up sharing a common base class then // DrawAssemblyFilter() and DrawAreaFilter() can be made to call a common method and just pass the selection, names // and the type of window we want. void DrawAreaFilter() { if (!activeView.desc.showAreaSelection) { return; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Contents.AreaFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); if (AreaNames.Length > 0) { var lastEnabled = GUI.enabled; var enabled = IsAnalysisValid() && !AreaSelectionWindow.IsOpen(); GUI.enabled = enabled; if (GUILayout.Button(Contents.AreaFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AreaSelectionWindow.IsOpen()) { AreaSelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AreaSelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AreaSelection, AreaNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AreaSelect, analytic); } GUI.enabled = lastEnabled; m_AreaSelectionSummary = GetSelectedAreasSummary(); Utility.DrawSelectedText(m_AreaSelectionSummary); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); }
void OnViewChanged(object userData) { var index = (int)userData; var activeViewChanged = (m_ActiveViewIndex != index); if (activeViewChanged) { m_ActiveViewIndex = index; activeView.Refresh(); ProjectAuditorAnalytics.SendUIButtonEvent((ProjectAuditorAnalytics.UIButton)activeView.desc.analyticsEvent, ProjectAuditorAnalytics.BeginAnalytic()); } }
void Export(Func <ProjectIssue, bool> match = null) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); if (IsAnalysisValid()) { var path = EditorUtility.SaveFilePanel("Save analysis CSV data", "", "project-auditor-report.csv", "csv"); if (path.Length != 0) { m_ProjectReport.ExportToCSV(path, issue => m_ProjectAuditor.config.GetAction(issue.descriptor, issue.callingMethod) != Rule.Action.None && (match == null || match(issue))); } } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); }
void Analyze() { m_AnalyzeButtonAnalytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ShouldRefresh = true; m_AnalysisState = AnalysisState.InProgress; m_ProjectReport = new ProjectReport(); foreach (var view in m_Views) { if (view != null) { view.Clear(); } } AnalysisView.SetReport(m_ProjectReport); var newIssues = new List <ProjectIssue>(); m_ProjectAuditor.Audit(projectIssue => { newIssues.Add(projectIssue); m_ProjectReport.AddIssue(projectIssue); }, completed => { // add batch of issues foreach (var view in m_Views) { if (view != null) { view.AddIssues(newIssues); } } newIssues.Clear(); if (completed) { m_AnalysisState = AnalysisState.Completed; } m_ShouldRefresh = true; }, new ProgressBarDisplay() ); }
void Analyze() { m_AnalyzeButtonAnalytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ShouldRefresh = true; m_AnalysisState = AnalysisState.InProgress; m_ProjectReport = new ProjectReport(); foreach (var view in m_AnalysisViews) { view.Clear(); } var newIssues = new List <ProjectIssue>(); try { m_ProjectAuditor.Audit(projectIssue => { newIssues.Add(projectIssue); m_ProjectReport.AddIssue(projectIssue); }, completed => { // add batch of issues foreach (var view in m_AnalysisViews) { view.AddIssues(newIssues); } newIssues.Clear(); if (completed) { m_AnalysisState = AnalysisState.Completed; } m_ShouldRefresh = true; }, new ProgressBarDisplay()); } catch (AssemblyCompilationException e) { m_AnalysisState = AnalysisState.NotStarted; Debug.LogError(e); } }
void DrawAssemblyFilter() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.AssemblyFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); var lastEnabled = GUI.enabled; GUI.enabled = m_AnalysisState == AnalysisState.Valid && !AssemblySelectionWindow.IsOpen() && activeAnalysisView.desc.showAssemblySelection; if (GUILayout.Button(Styles.AssemblyFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { if (m_AssemblyNames != null && m_AssemblyNames.Length > 0) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AssemblySelectionWindow.IsOpen()) { AssemblySelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AssemblySelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AssemblySelection, m_AssemblyNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AssemblySelect, analytic); } } GUI.enabled = lastEnabled; m_AssemblySelectionSummary = GetSelectedAssembliesSummary(); DrawSelectedText(m_AssemblySelectionSummary); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
// stephenm TODO - if AssemblySelectionWindow and AreaSelectionWindow end up sharing a common base class then // DrawAssemblyFilter() and DrawAreaFilter() can be made to call a common method and just pass the selection, names // and the type of window we want. private void DrawAreaFilter() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.AreaFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); if (m_AreaNames.Length > 0) { var lastEnabled = GUI.enabled; // stephenm TODO - We don't currently have any sense of when the Auditor is busy and should disallow user input var enabled = /*!IsAnalysisRunning() &&*/ !AreaSelectionWindow.IsOpen(); GUI.enabled = enabled; if (GUILayout.Button(Styles.AreaFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AreaSelectionWindow.IsOpen()) { AreaSelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AreaSelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AreaSelection, m_AreaNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AreaSelect, analytic); } GUI.enabled = lastEnabled; m_AreaSelectionSummary = GetSelectedAreasSummary(); DrawSelectedText(m_AreaSelectionSummary); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); }
void DrawMode() { EditorGUILayout.BeginHorizontal(); var activeModeIndex = GUILayout.Toolbar(m_ActiveModeIndex, m_ModeNames, "LargeButton", GUILayout.Height(LayoutSize.ToolbarHeight)); EditorGUILayout.EndHorizontal(); bool activeModeChanged = (m_ActiveModeIndex != activeModeIndex); if (activeModeChanged) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ActiveModeIndex = activeModeIndex; RefreshDisplay(); ProjectAuditorAnalytics.SendUIButtonEvent(activeAnalysisView.desc.analyticsEvent, analytic); } }
private void RefreshDisplay() { if (!IsAnalysisValid()) { return; } if (m_AnalysisState == AnalysisState.Completed) { // update list of assembly names var scriptIssues = m_ProjectReport.GetIssues(IssueCategory.ApiCalls); m_AssemblyNames = scriptIssues.Select(i => i.assembly).Distinct().OrderBy(str => str).ToArray(); UpdateAssemblySelection(); m_AnalysisState = AnalysisState.Valid; ProjectAuditorAnalytics.SendUIButtonEventWithAnalyzeSummary(ProjectAuditorAnalytics.UIButton.Analyze, m_AnalyzeButtonAnalytic, m_ProjectReport); } m_ActiveIssueTable.Reload(); }
void Load() { var path = EditorUtility.OpenFilePanel("Load from json file", m_SaveLoadDirectory, "json"); if (path.Length != 0) { m_LoadButtonAnalytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ProjectReport = ProjectReport.Load(path); m_AnalysisState = AnalysisState.Valid; m_SaveLoadDirectory = Path.GetDirectoryName(path); } OnEnable(); UpdateAssemblyNames(); UpdateAssemblySelection(); // switch to summary view after loading SelectView(IssueCategory.MetaData); }
void RefreshDisplay() { if (!IsAnalysisValid()) { return; } if (m_AnalysisState == AnalysisState.Completed) { // update list of assembly names var scriptIssues = m_ProjectReport.GetIssues(IssueCategory.Code); m_AssemblyNames = scriptIssues.Select(i => i.GetCustomProperty((int)CustomProperty.Assembly)).Distinct().OrderBy(str => str).ToArray(); UpdateAssemblySelection(); m_AnalysisState = AnalysisState.Valid; ProjectAuditorAnalytics.SendUIButtonEventWithAnalyzeSummary(ProjectAuditorAnalytics.UIButton.Analyze, m_AnalyzeButtonAnalytic, m_ProjectReport); } activeAnalysisView.Refresh(); }
private void DrawToolbar() { EditorGUILayout.BeginHorizontal(GUI.skin.box); { GUI.enabled = (m_AnalysisState == AnalysisState.Valid || m_AnalysisState == AnalysisState.NotStarted); if (GUILayout.Button(Styles.AnalyzeButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { Analyze(); } GUI.enabled = m_AnalysisState == AnalysisState.Valid; if (GUILayout.Button(Styles.ExportButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); Export(); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); } GUI.enabled = true; if (m_DeveloperMode) { if (GUILayout.Button(Styles.ReloadButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { Reload(); } } if (m_AnalysisState == AnalysisState.InProgress) { GUILayout.Label(Styles.AnalysisInProgressLabel, GUILayout.ExpandWidth(true)); } } EditorGUILayout.EndHorizontal(); }
void ApplySelection() { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selection = m_MultiSelectionTable.GetTreeViewSelection(); m_ProjectAuditorWindow.SetAssemblySelection(selection); var payload = new Dictionary <string, string>(); string[] selectedAsmNames = selection.GetSelectedStrings(m_Names, false); if (selectedAsmNames == null || selectedAsmNames.Length == 0) { payload["numSelected"] = "0"; payload["numUnityAssemblies"] = "0"; } else { payload["numSelected"] = selectedAsmNames.Length.ToString(); payload["numUnityAssemblies"] = selectedAsmNames.Where(name => name.Contains("Unity")).Count().ToString(); } ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.AssemblySelectApply, analytic, payload); }
void Export(Func <ProjectIssue, bool> match = null) { var path = EditorUtility.SaveFilePanel("Save to CSV file", s_ExportDirectory, string.Format("project-auditor-{0}.csv", m_Desc.category.ToString()).ToLower(), "csv"); if (path.Length != 0) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); using (var exporter = new Exporter(path, m_Layout)) { exporter.WriteHeader(); var matchingIssues = m_Issues.Where(issue => m_Config.GetAction(issue.descriptor, issue.GetCallingMethod()) != Rule.Severity.None && (match == null || match(issue))); exporter.WriteIssues(matchingIssues.ToArray()); } EditorUtility.RevealInFinder(path); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); s_ExportDirectory = Path.GetDirectoryName(path); } }
private void DrawFilters() { if (!IsAnalysisValid()) { return; } EditorGUILayout.BeginVertical( GUI.skin.box /*, GUILayout.Width(LayoutSize.ToolbarWidth), GUILayout.ExpandWidth(true)*/); { EditorGUILayout.BeginHorizontal(); var activeModeIndex = GUILayout.Toolbar(m_ActiveModeIndex, m_ModeNames, GUILayout.MaxWidth(LayoutSize.ModeTabWidth) /*, GUILayout.ExpandWidth(true)*/); EditorGUILayout.EndHorizontal(); DrawAssemblyFilter(); DrawAreaFilter(); EditorGUI.BeginChangeCheck(); var searchRect = GUILayoutUtility.GetRect(1, 1, 18, 18, GUILayout.ExpandWidth(true), GUILayout.Width(200)); EditorGUILayout.BeginHorizontal(); if (m_SearchField == null) { m_SearchField = new SearchField(); } m_SearchText = m_SearchField.OnGUI(searchRect, m_SearchText); m_ActiveIssueTable.searchString = m_SearchText; EditorGUILayout.EndHorizontal(); var shouldRefresh = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Selected :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); if (GUILayout.Button(Styles.MuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = m_ActiveIssueTable.GetSelectedItems(); foreach (var item in selectedItems) { SetRuleForItem(item, Rule.Action.None); } if (!m_ProjectAuditor.config.DisplayMutedIssues) { m_ActiveIssueTable.SetSelection(new List <int>()); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary(ProjectAuditorAnalytics.UIButton.Mute, analytic, m_ActiveIssueTable.GetSelectedItems()); } if (GUILayout.Button(Styles.UnmuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = m_ActiveIssueTable.GetSelectedItems(); foreach (var item in selectedItems) { ClearRulesForItem(item); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary(ProjectAuditorAnalytics.UIButton.Unmute, analytic, m_ActiveIssueTable.GetSelectedItems()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); GUI.enabled = m_ActiveAnalysisView.desc.showCritical; bool wasShowingCritical = m_ProjectAuditor.config.DisplayOnlyCriticalIssues; m_ProjectAuditor.config.DisplayOnlyCriticalIssues = EditorGUILayout.ToggleLeft("Only Critical Issues", m_ProjectAuditor.config.DisplayOnlyCriticalIssues, GUILayout.Width(160)); GUI.enabled = true; if (wasShowingCritical != m_ProjectAuditor.config.DisplayOnlyCriticalIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_ActiveAnalysisView.desc.showCritical ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.OnlyCriticalIssues, analytic); } bool wasDisplayingMuted = m_ProjectAuditor.config.DisplayMutedIssues; m_ProjectAuditor.config.DisplayMutedIssues = EditorGUILayout.ToggleLeft("Muted Issues", m_ProjectAuditor.config.DisplayMutedIssues, GUILayout.Width(127)); if (wasDisplayingMuted != m_ProjectAuditor.config.DisplayMutedIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_ProjectAuditor.config.DisplayMutedIssues ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.ShowMuted, analytic, payload); } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { shouldRefresh = true; } bool activeModeChanged = (m_ActiveModeIndex != activeModeIndex); if (activeModeChanged) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ActiveModeIndex = activeModeIndex; RefreshDisplay(); if (m_ActiveModeIndex == (int)IssueCategory.ApiCalls) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.ApiCalls, analytic); } else if (m_ActiveModeIndex == (int)IssueCategory.ProjectSettings) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.ProjectSettings, analytic); } else { Debug.LogWarning("Unrecognised active mode: couldn't sent analytics event"); } } else if (shouldRefresh || m_ShouldRefresh || m_AnalysisState == AnalysisState.Completed) { RefreshDisplay(); m_ShouldRefresh = false; } } EditorGUILayout.EndVertical(); }
void DrawFilters() { EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true)); m_Preferences.filters = BoldFoldout(m_Preferences.filters, Styles.FiltersFoldout); if (m_Preferences.filters) { EditorGUI.indentLevel++; DrawAssemblyFilter(); DrawAreaFilter(); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.TextSearchLabel, GUILayout.Width(80)); m_TextFilter.searchText = EditorGUILayout.DelayedTextField(m_TextFilter.searchText, GUILayout.Width(180)); activeAnalysisView.table.searchString = m_TextFilter.searchText; m_TextFilter.matchCase = EditorGUILayout.ToggleLeft(Styles.TextSearchCaseSensitive, m_TextFilter.matchCase, GUILayout.Width(160)); if (m_DeveloperMode) { // this is only available in developer mode because it is still too slow at the moment GUI.enabled = activeAnalysisView.desc.showDependencyView; m_TextFilter.searchDependencies = EditorGUILayout.ToggleLeft("Call Tree (slow)", m_TextFilter.searchDependencies, GUILayout.Width(160)); GUI.enabled = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); GUI.enabled = activeAnalysisView.desc.showCritical; bool wasShowingCritical = m_Preferences.onlyCriticalIssues; m_Preferences.onlyCriticalIssues = EditorGUILayout.ToggleLeft("Only Critical Issues", m_Preferences.onlyCriticalIssues, GUILayout.Width(160)); GUI.enabled = true; if (wasShowingCritical != m_Preferences.onlyCriticalIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = activeAnalysisView.desc.showCritical ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.OnlyCriticalIssues, analytic); } bool wasDisplayingMuted = m_Preferences.mutedIssues; m_Preferences.mutedIssues = EditorGUILayout.ToggleLeft("Muted Issues", m_Preferences.mutedIssues, GUILayout.Width(127)); if (wasDisplayingMuted != m_Preferences.mutedIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_Preferences.mutedIssues ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.ShowMuted, analytic, payload); } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { m_ShouldRefresh = true; } EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); }
void OnEnable() { var currentState = m_AnalysisState; m_AnalysisState = AnalysisState.Initializing; ProjectAuditorAnalytics.EnableAnalytics(); m_ProjectAuditor = new ProjectAuditor(); UpdateAreaSelection(); UpdateAssemblySelection(); if (m_TextFilter == null) { m_TextFilter = new TextFilter(); } var viewDescriptors = ViewDescriptor.GetAll(); Array.Sort(viewDescriptors, (a, b) => a.menuOrder.CompareTo(b.menuOrder)); m_ViewDropdownItems = new Utility.DropdownItem[viewDescriptors.Length]; m_Views = new AnalysisView[viewDescriptors.Length]; for (int i = 0; i < viewDescriptors.Length; i++) { var desc = viewDescriptors[i]; var layout = m_ProjectAuditor.GetLayout(desc.category); var isSupported = layout != null; m_ViewDropdownItems[i] = new Utility.DropdownItem { Content = new GUIContent(string.IsNullOrEmpty(desc.menuLabel) ? desc.name : desc.menuLabel), SelectionContent = new GUIContent("View: " + desc.name), Enabled = isSupported }; if (!isSupported) { Debug.Log("Project Auditor module " + desc.category + " is not supported."); continue; } var view = desc.viewType != null ? (AnalysisView)Activator.CreateInstance(desc.viewType) : new AnalysisView(); view.Create(desc, layout, m_ProjectAuditor.config, m_Preferences, this); if (currentState == AnalysisState.Valid) { view.AddIssues(m_ProjectReport.GetIssues(desc.category)); } m_Views[i] = view; } if (currentState != AnalysisState.Valid) { m_ProjectReport = new ProjectReport(); } AnalysisView.SetReport(m_ProjectReport); AnalysisView.OnChangeView = SelectView; GetView <ShaderVariantsView>().SetShadersAuditor(m_ProjectAuditor.GetAuditor <ShadersAuditor>()); // are we reloading from a valid state? if (currentState == AnalysisState.Valid && m_ActiveViewIndex < viewDescriptors.Length) { m_AnalysisState = currentState; } else { m_AnalysisState = AnalysisState.Initialized; } RefreshDisplay(); Instance = this; }