public static void EndVerticalSplit() => SplitterGUILayout.EndVerticalSplit();
void OnGUI() { Event e = Event.current; LoadIcons(); LogEntries.wrapped.UpdateEntries(); if (!m_HasUpdatedGuiStyles) { m_LineHeight = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight); m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom; UpdateListView(); } GUILayout.BeginHorizontal(Constants.Toolbar); if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton)) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.wrapped.GetCount(); if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0) { // scroll bar was at the bottom? if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight; } } if (LogEntries.wrapped.searchFrame) { LogEntries.wrapped.searchFrame = false; int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex(); if (selectedIndex != -1) { int showIndex = selectedIndex + 1; if (currCount > showIndex) { int showCount = ms_LVHeight / RowHeight; showIndex = showIndex + showCount / 2; } m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight; } } EditorGUILayout.Space(); bool wasCollapsed = LogEntries.wrapped.collapse; LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton); bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight; } SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton)); #if UNITY_2019_1_OR_NEWER SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton)); #endif SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton)); #if UNITY_2018_3_OR_NEWER ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown); #endif EditorGUILayout.Space(); if (m_DevBuild) { GUILayout.FlexibleSpace(); SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton)); SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton)); } GUILayout.FlexibleSpace(); // Search bar GUILayout.Space(4f); SearchField(e); int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { } LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag); LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag); if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton)) { int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex(); if (firstErrorIndex != -1) { SetActiveEntry(firstErrorIndex); LogEntries.wrapped.searchFrame = true; } } GUILayout.EndHorizontal(); SplitterGUILayout.BeginVerticalSplit(spl); int rowHeight = RowHeight; EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight)); GUIContent tempContent = new GUIContent(); int id = GUIUtility.GetControlID(0); int rowDoubleClicked = -1; /////@TODO: Make Frame selected work with ListViewState using (new GettingLogEntriesScope(m_ListView)) { int selectedRow = -1; bool openSelectedItem = false; bool collapsed = LogEntries.wrapped.collapse; foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box)) { if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { m_ListView.row = el.row; selectedRow = el.row; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; int entryCount = 0; int searchIndex = 0; int searchEndIndex = 0; string text = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount, ref searchIndex, ref searchEndIndex); ConsoleFlags flag = (ConsoleFlags)mode; bool isSelected = LogEntries.wrapped.IsEntrySelected(el.row); // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, isSelected, false); // Draw the icon #if !UNITY_2017_3_OR_NEWER if (Constants.LogStyleLineCount == 1) { Rect rt = el.position; rt.x += 6f; rt.y += 2f; rt.width = 16f; rt.height = 16f; GUI.DrawTexture(rt, GetIconForErrorMode(flag, false)); } else #endif { GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1); iconStyle.Draw(el.position, false, false, isSelected, false); } // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1); if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length) { errorModeStyle.Draw(el.position, tempContent, id, isSelected); } else { errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex); } if (collapsed) { Rect badgeRect = el.position; tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); badgeRect.xMin = badgeRect.xMax - badgeSize.x; badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f; badgeRect.x -= 5f; GUI.Label(badgeRect, tempContent, Constants.CountBadge); } } } if (selectedRow != -1) { if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight) { m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1; } } // Make sure the selected entry is up to date if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0) { } else { if (m_ListView.selectionChanged) { SetActiveEntry(m_ListView.row); } } // Open entry using return key if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0)) { selectedRow = m_ListView.row; openSelectedItem = true; } if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { ms_LVHeight = ListViewGUI.ilvState.rectHeight; } if (openSelectedItem) { rowDoubleClicked = selectedRow; e.Use(); } if (selectedRow != -1) { SetActiveEntry(selectedRow); } } // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060. if (rowDoubleClicked != -1) { LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked(); } EditorGUIUtility.SetIconSize(Vector2.zero); StacktraceListView(e, tempContent); SplitterGUILayout.EndVerticalSplit(); // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy") { if (e.type == EventType.ExecuteCommand) { LogEntries.wrapped.StacktraceListView_CopyAll(); } e.Use(); } }
public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.valid || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); var selectedMergedSampleIndex = m_TreeView.GetSelectedFrameDataViewMergedSampleIndex(); var selectedSampleMetadataCount = 0; if (selectedSampleId != -1) { frameDataView.GetItemMergedSampleCallstack(selectedSampleId, selectedMergedSampleIndex, m_CachedCallstack); selectedSampleMetadataCount = frameDataView.GetItemMergedSamplesMetadataCount(selectedSampleId, selectedMergedSampleIndex); } var showCallstack = m_CachedCallstack.Count > 0; var showMetadata = selectedSampleMetadataCount != 0; SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); // Callstack area EditorGUILayout.BeginVertical(Styles.expandedArea); // Display active text (We want word wrapped text with a vertical scrollbar) m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var sb = new StringBuilder(); if (showMetadata || showCallstack) { if (showMetadata) { var metadataInfo = frameDataView.GetMarkerMetadataInfo(frameDataView.GetItemMarkerID(selectedSampleId)); sb.Append(kMetadataText); sb.Append('\n'); for (var i = 0; i < selectedSampleMetadataCount; ++i) { if (metadataInfo != null && i < metadataInfo.Length) { sb.Append(metadataInfo[i].name); } else { sb.Append(i); } sb.Append(": "); sb.Append(frameDataView.GetItemMergedSamplesMetadata(selectedSampleId, selectedMergedSampleIndex, i)); sb.Append('\n'); } sb.Append('\n'); } if (showCallstack) { sb.Append(kCallstackText); sb.Append('\n'); foreach (var addr in m_CachedCallstack) { var methodInfo = frameDataView.ResolveMethodInfo(addr); if (string.IsNullOrEmpty(methodInfo.methodName)) { sb.AppendFormat("0x{0:X}\n", addr); } else if (string.IsNullOrEmpty(methodInfo.sourceFileName)) { sb.AppendFormat("0x{0:X}\t\t{1}\n", addr, methodInfo.methodName); } else { var normalizedPath = methodInfo.sourceFileName.Replace('\\', '/'); if (methodInfo.sourceFileLine == 0) { sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"1\">{2}</a>\n", addr, methodInfo.methodName, normalizedPath); } else { sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"{3}\">{2}:{3}</a>\n", addr, methodInfo.methodName, normalizedPath, methodInfo.sourceFileLine); } } } } } else { sb.Append(kNoMetadataOrCallstackText); } var metadataText = sb.ToString(); Styles.callstackTextArea.CalcMinMaxWidth(GUIContent.Temp(metadataText), out _, out var maxWidth); float minHeight = Styles.callstackTextArea.CalcHeight(GUIContent.Temp(metadataText), maxWidth); EditorGUILayout.SelectableLabel(metadataText, Styles.callstackTextArea, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(maxWidth + 10), GUILayout.MinHeight(minHeight + 10)); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.valid || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); if (selectedSampleId != -1) { frameDataView.GetItemMergedSampleCallstack(selectedSampleId, m_TreeView.state.selectedIDs[0], m_CachedCallstack); } var showCallstack = m_CachedCallstack.Count > 0; if (showCallstack) { SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); } // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); if (showCallstack) { // Callstack area EditorGUILayout.BeginVertical(Styles.expandedArea); m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var sb = new StringBuilder(kCallstackText + '\n'); foreach (var addr in m_CachedCallstack) { var methodInfo = frameDataView.ResolveMethodInfo(addr); if (string.IsNullOrEmpty(methodInfo.methodName)) { sb.AppendFormat("0x{0:X}\n", addr); } else if (string.IsNullOrEmpty(methodInfo.sourceFileName)) { sb.AppendFormat("0x{0:X}\t\t{1}\n", addr, methodInfo.methodName); } else if (methodInfo.sourceFileLine == 0) { sb.AppendFormat("0x{0:X}\t\t{1}\t{2}\n", addr, methodInfo.methodName, methodInfo.sourceFileName); } else { sb.AppendFormat("0x{0:X}\t\t{1}\t{2}:{3}\n", addr, methodInfo.methodName, methodInfo.sourceFileName, methodInfo.sourceFileLine); } } EditorGUILayout.TextArea(sb.ToString(), Styles.callstackTextArea); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); } }
public void OnGUI() { if (!m_Enabled) { Enable(); } if (BuildPipeline.isBuildingPlayer) { m_IsBuilding = true; } else if (m_IsBuilding) { m_IsBuilding = false; Repaint(); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var selectedIndex = m_TestTypeToolbarIndex; m_TestTypeToolbarIndex = GUILayout.Toolbar(m_TestTypeToolbarIndex, Enum.GetNames(typeof(TestRunnerMenuLabels)), "LargeButton", UnityEngine.GUI.ToolbarButtonSize.FitToContents); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (selectedIndex != m_TestTypeToolbarIndex) { SelectTestListGUI(m_TestTypeToolbarIndex); StartRetrieveTestList(); } EditorGUILayout.BeginVertical(); using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode)) { m_SelectedTestTypes.PrintHeadPanel(); } EditorGUILayout.EndVertical(); if (m_Settings.verticalSplit) { SplitterGUILayout.BeginVerticalSplit(m_Spl); } else { SplitterGUILayout.BeginHorizontalSplit(m_Spl); } EditorGUILayout.BeginVertical(); EditorGUILayout.BeginVertical(Styles.testList); m_SelectedTestTypes.RenderTestList(); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); m_SelectedTestTypes.RenderDetails(); if (m_Settings.verticalSplit) { SplitterGUILayout.EndVerticalSplit(); } else { SplitterGUILayout.EndHorizontalSplit(); } }
public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection) { if (frameDataView == null || !frameDataView.valid || selection.Count == 0) { DrawEmptyPane(headerStyle); return; } InitIfNeeded(); UpdateIfNeeded(frameDataView, selection[0]); var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId(); var selectedMergedSampleIndex = m_TreeView.GetSelectedFrameDataViewMergedSampleIndex(); var selectedSampleMetadataCount = 0; if (selectedSampleId != -1) { frameDataView.GetItemMergedSampleCallstack(selectedSampleId, selectedMergedSampleIndex, m_CachedCallstack); selectedSampleMetadataCount = frameDataView.GetItemMergedSamplesMetadataCount(selectedSampleId, selectedMergedSampleIndex); } GUILayout.Label(m_InstancesLabel, EditorStyles.label); var showCallstack = m_CachedCallstack.Count > 0; var showMetadata = selectedSampleMetadataCount != 0; SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea); // Detailed list var rect = EditorGUILayout.BeginVertical(Styles.expandedArea); m_TreeView.OnGUI(rect); EditorGUILayout.EndVertical(); // Metadata area EditorGUILayout.BeginVertical(Styles.expandedArea); if (showCallstack) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); ProfilerFrameDataViewBase.showFullDetailsForCallStacks = GUILayout.Toggle(ProfilerFrameDataViewBase.showFullDetailsForCallStacks, ProfilerFrameDataViewBase.showFullDetailsForCallStacksContent, EditorStyles.toolbarButton); EditorGUILayout.EndHorizontal(); } // Display active text (We want word wrapped text with a vertical scrollbar) m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll); var sb = new StringBuilder(); if (showMetadata || showCallstack) { if (showMetadata) { var metadataInfo = frameDataView.GetMarkerMetadataInfo(frameDataView.GetItemMarkerID(selectedSampleId)); sb.Append(kMetadataText); sb.Append('\n'); for (var i = 0; i < selectedSampleMetadataCount; ++i) { if (metadataInfo != null && i < metadataInfo.Length) { sb.Append(metadataInfo[i].name); } else { sb.Append(i); } sb.Append(": "); sb.Append(frameDataView.GetItemMergedSamplesMetadata(selectedSampleId, selectedMergedSampleIndex, i)); sb.Append('\n'); } sb.Append('\n'); } if (showCallstack) { m_ProfilerFrameDataHierarchyView.CompileCallStack(sb, m_CachedCallstack, frameDataView); } } else { sb.Append(kNoMetadataOrCallstackText); } var metadataText = sb.ToString(); Styles.callstackTextArea.CalcMinMaxWidth(GUIContent.Temp(metadataText), out _, out var maxWidth); float minHeight = Styles.callstackTextArea.CalcHeight(GUIContent.Temp(metadataText), maxWidth); EditorGUILayout.SelectableLabel(metadataText, Styles.callstackTextArea, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(maxWidth + 10), GUILayout.MinHeight(minHeight + 10)); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }