public static void ShowConsoleWindow(bool immediate) { if (ms_ConsoleWindow == null) { ms_ConsoleWindow = ScriptableObject.CreateInstance <ConsoleWindow>(); ms_ConsoleWindow.Show(immediate); ms_ConsoleWindow.Focus(); } else { ms_ConsoleWindow.Show(immediate); ms_ConsoleWindow.Focus(); } }
public static void ShowConsoleWindow(bool immediate) { if ((UnityEngine.Object) ConsoleWindow.ms_ConsoleWindow == (UnityEngine.Object) null) { ConsoleWindow.ms_ConsoleWindow = ScriptableObject.CreateInstance<ConsoleWindow>(); ConsoleWindow.ms_ConsoleWindow.Show(immediate); ConsoleWindow.ms_ConsoleWindow.Focus(); } else { ConsoleWindow.ms_ConsoleWindow.Show(immediate); ConsoleWindow.ms_ConsoleWindow.Focus(); } }
void OnEnable() { if (m_ConsoleAttachToPlayerState == null) { m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this); } MakeSureConsoleAlwaysOnlyOne(); titleContent = GetLocalizedTitleContent(); ms_ConsoleWindow = this; m_DevBuild = Unsupported.IsDeveloperMode(); Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2); }
internal static Texture2D GetIconForErrorMode(int mode, bool large) { if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 1050963)) { return((!large) ? ConsoleWindow.iconErrorSmall : ConsoleWindow.iconError); } if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 4736)) { return((!large) ? ConsoleWindow.iconWarnSmall : ConsoleWindow.iconWarn); } if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 1028)) { return((!large) ? ConsoleWindow.iconInfoSmall : ConsoleWindow.iconInfo); } return(null); }
internal void OnEnable() { if (m_ConsoleAttachToPlayerState == null) { m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this); } // Update the filter on enable for DomainReload(keep current filter) and window opening(reset filter because m_searchText is null) SetFilter(LogEntries.GetFilteringText()); titleContent = GetLocalizedTitleContent(); ms_ConsoleWindow = this; m_DevBuild = Unsupported.IsDeveloperMode(); Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2); }
internal static GUIStyle GetStyleForErrorMode(int mode) { GUIStyle result; if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 3148115)) { result = ConsoleWindow.Constants.ErrorStyle; } else if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 4736)) { result = ConsoleWindow.Constants.WarningStyle; } else { result = ConsoleWindow.Constants.LogStyle; } return(result); }
internal static GUIStyle GetStatusStyleForErrorMode(int mode) { GUIStyle result; if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 3148115)) { result = ConsoleWindow.Constants.StatusError; } else if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 4736)) { result = ConsoleWindow.Constants.StatusWarn; } else { result = ConsoleWindow.Constants.StatusLog; } return(result); }
public static void ShowConsoleWindow(bool immediate) { if (ms_ConsoleWindow == null) { ms_ConsoleWindow = ScriptableObject.CreateInstance <ConsoleWindow>(); if (UnityEditor.MPE.ProcessService.level == MPE.ProcessLevel.Master) { ms_ConsoleWindow.Show(immediate); } else { ms_ConsoleWindow.ShowModalUtility(); } ms_ConsoleWindow.Focus(); } else { ms_ConsoleWindow.Show(immediate); ms_ConsoleWindow.Focus(); } }
internal static Texture2D GetIconForErrorMode(int mode, bool large) { Texture2D result; if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 3148115)) { result = ((!large) ? ConsoleWindow.iconErrorSmall : ConsoleWindow.iconError); } else if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 4736)) { result = ((!large) ? ConsoleWindow.iconWarnSmall : ConsoleWindow.iconWarn); } else if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 1028)) { result = ((!large) ? ConsoleWindow.iconInfoSmall : ConsoleWindow.iconInfo); } else { result = null; } return(result); }
private void DrawStatusText() { string statusText = LogEntries.GetStatusText(); if (String.IsNullOrEmpty(statusText)) { return; } int mask = LogEntries.GetStatusMask(); GUIStyle errorStyle = ConsoleWindow.GetStatusStyleForErrorMode(mask); Texture2D icon = ConsoleWindow.GetIconForErrorMode(mask, false); GUILayout.Label(icon, errorStyle); var iconRect = GUILayoutUtility.GetLastRect(); GUILayout.Space(2); GUILayout.BeginVertical(); GUILayout.Space(1); GUILayout.Label(statusText, errorStyle, GetStatusTextLayoutOption((icon != null ? icon.width : 0) + 6)); // Handle status bar click if (Event.current.type == EventType.MouseDown) { var labelRect = GUILayoutUtility.GetLastRect(); if (iconRect.Contains(Event.current.mousePosition) || labelRect.Contains(Event.current.mousePosition)) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } GUILayout.EndVertical(); }
protected override void OldOnGUI() { ConsoleWindow.LoadIcons(); GUI.color = EditorApplication.isPlayingOrWillChangePlaymode ? HostView.kPlayModeDarken : Color.white; if (Event.current.type == EventType.Layout) { m_ShowProgress = Progress.running && Progress.GetMaxElapsedTime() > k_ShowProgressThreshold; } else if (Event.current.type == EventType.Repaint) { Styles.background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } GUILayout.BeginHorizontal(GUILayout.MaxWidth(position.width)); { GUILayout.Space(2); DrawStatusText(); GUILayout.FlexibleSpace(); if (m_DrawExtraFeatures) { DrawSpecialModeLabel(); } DrawProgressBar(); DrawDebuggerToggle(); if (m_DrawExtraFeatures) { DrawCacheServerToggle(); DrawBakeMode(); } DrawRefreshStatus(); } GUILayout.EndHorizontal(); DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
private static bool HasMode(int mode, ConsoleWindow.Mode modeToCheck) { return (mode & (int)modeToCheck) != 0; }
private void OnDisable() { if (ConsoleWindow.ms_ConsoleWindow == this) { ConsoleWindow.ms_ConsoleWindow = null; } }
private void OnEnable() { ConsoleWindow.ms_ConsoleWindow = this; this.m_DevBuild = Unsupported.IsDeveloperBuild(); }
private void OnDisable() { if (!((UnityEngine.Object) ConsoleWindow.ms_ConsoleWindow == (UnityEngine.Object) this)) return; ConsoleWindow.ms_ConsoleWindow = (ConsoleWindow) null; }
private void OnEnable() { this.titleContent = this.GetLocalizedTitleContent(); ConsoleWindow.ms_ConsoleWindow = this; this.m_DevBuild = Unsupported.IsDeveloperBuild(); }
protected override void OldOnGUI() { ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } if (EditorApplication.isPlayingOrWillChangePlaymode) { GUI.color = HostView.kPlayModeDarken; } if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } bool compiling = EditorApplication.isCompiling; GUILayout.Space(2); GUILayout.BeginHorizontal(); GUILayout.Space(2); string statusText = LogEntries.GetStatusText(); if (statusText != null) { // Render int mask = LogEntries.GetStatusMask(); GUIStyle errorStyle = ConsoleWindow.GetStatusStyleForErrorMode(mask); GUILayout.Label(ConsoleWindow.GetIconForErrorMode(mask, false), errorStyle); GUILayout.Space(2); GUILayout.BeginVertical(); GUILayout.Space(2); if (compiling) //leave space for indicator { GUILayout.Label(statusText, errorStyle, GUILayout.MaxWidth(GUIView.current.position.width - 52)); } else { GUILayout.Label(statusText, errorStyle); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); // Handle status bar click if (Event.current.type == EventType.MouseDown) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { const float statusWheelWidth = 24; const float progressBarStatusWheelSpacing = 3; float progressBarHorizontalPosition = position.width - statusWheelWidth; if (AsyncProgressBar.isShowing) { const int progressBarWidth = 185; progressBarHorizontalPosition -= progressBarWidth + progressBarStatusWheelSpacing; EditorGUI.ProgressBar(new Rect(progressBarHorizontalPosition, 0, progressBarWidth, 19), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (compiling) { int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); } if (Unsupported.IsBleedingEdgeBuild()) { var backup = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(progressBarHorizontalPosition - 310, 0, 310, 19), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUI.Label(new Rect(progressBarHorizontalPosition - 200, 0, 200, 19), m_LastMiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(m_LastMiniMemoryOverview); } } DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
private void SetTimestamp() { ConsoleWindow.SetFlag(ConsoleWindow.ConsoleFlags.ShowTimestamp, !ConsoleWindow.HasFlag(ConsoleWindow.ConsoleFlags.ShowTimestamp)); }
private bool HasFlag(ConsoleWindow.ConsoleFlags flags) { return ((ConsoleWindow.ConsoleFlags) LogEntries.consoleFlags & flags) != (ConsoleWindow.ConsoleFlags) 0; }
private static bool HasMode(int mode, ConsoleWindow.Mode modeToCheck) { return ((ConsoleWindow.Mode) mode & modeToCheck) != (ConsoleWindow.Mode) 0; }
private bool HasFlag(ConsoleWindow.ConsoleFlags flags) { return (LogEntries.consoleFlags & (int)flags) != 0; }
private static void ShowConsoleWindowImmediate() { ConsoleWindow.ShowConsoleWindow(true); }
private void SetFlag(ConsoleWindow.ConsoleFlags flags, bool val) { LogEntries.SetConsoleFlag((int)flags, val); }
public void AddItemsToMenu(GenericMenu menu) { if (Application.platform == RuntimePlatform.OSXEditor) { GUIContent arg_36_1 = EditorGUIUtility.TrTextContent("Open Player Log", null, null); bool arg_36_2 = false; if (ConsoleWindow.< > f__mg$cache0 == null) { ConsoleWindow.< > f__mg$cache0 = new GenericMenu.MenuFunction(InternalEditorUtility.OpenPlayerConsole); } menu.AddItem(arg_36_1, arg_36_2, ConsoleWindow.< > f__mg$cache0); } GUIContent arg_66_1 = EditorGUIUtility.TrTextContent("Open Editor Log", null, null); bool arg_66_2 = false; if (ConsoleWindow.< > f__mg$cache1 == null) { ConsoleWindow.< > f__mg$cache1 = new GenericMenu.MenuFunction(InternalEditorUtility.OpenEditorConsole); } menu.AddItem(arg_66_1, arg_66_2, ConsoleWindow.< > f__mg$cache1); menu.AddItem(EditorGUIUtility.TrTextContent("Show Timestamp", null, null), ConsoleWindow.HasFlag(ConsoleWindow.ConsoleFlags.ShowTimestamp), new GenericMenu.MenuFunction(this.SetTimestamp)); for (int i = 1; i <= 10; i++) { string arg = (i != 1) ? "Lines" : "Line"; menu.AddItem(new GUIContent(string.Format("Log Entry/{0} {1}", i, arg)), i == ConsoleWindow.Constants.LogStyleLineCount, new GenericMenu.MenuFunction2(this.SetLogLineCount), i); } this.AddStackTraceLoggingMenu(menu); }
protected override void OldOnGUI() { const int spacing = 4; const int statusWheelWidth = 24; const int progressBarWidth = 185; float lightingBakeModeBarWidth = EditorStyles.progressBarText.CalcSize(EditorGUIUtility.TempContent(m_BakeModeString)).x; const int barHeight = 19; ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } GUI.color = EditorApplication.isPlayingOrWillChangePlaymode ? HostView.kPlayModeDarken : Color.white; if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false); } bool compiling = EditorApplication.isCompiling; bool assembliesLocked = !EditorApplication.CanReloadAssemblies(); GUILayout.BeginHorizontal(); GUILayout.Space(2); float statusBarItemsWidth = statusWheelWidth + (AsyncProgressBar.isShowing ? (progressBarWidth + spacing) : 0) + (showBakeMode ? (lightingBakeModeBarWidth + spacing) : 0); if (Event.current.type == EventType.MouseDown) { Rect rect = new Rect(position.width - statusBarItemsWidth - m_ManagedDebuggerToggle.GetWidth(), 0, lightingBakeModeBarWidth, barHeight); if (rect.Contains(Event.current.mousePosition)) { Event.current.Use(); LightingWindow.CreateLightingWindow(); } } string statusText = LogEntries.GetStatusText(); if (statusText != null) { // Render int mask = LogEntries.GetStatusMask(); GUIStyle errorStyle = ConsoleWindow.GetStatusStyleForErrorMode(mask); Texture2D icon = ConsoleWindow.GetIconForErrorMode(mask, false); GUILayout.Label(icon, errorStyle); GUILayout.Space(2); GUILayout.BeginVertical(); GUILayout.Space(1); float statusTextWidth = GUIView.current.position.width - statusBarItemsWidth - m_ManagedDebuggerToggle.GetWidth() - (icon != null ? icon.width : 0); GUILayout.Label(statusText, errorStyle, GUILayout.MaxWidth(statusTextWidth)); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); // Handle status bar click if (Event.current.type == EventType.MouseDown) { Rect rect = new Rect(0, 0, statusTextWidth, barHeight); if (rect.Contains(Event.current.mousePosition)) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } } float managedDebuggerTogglePosX = position.width - statusWheelWidth - m_ManagedDebuggerToggle.GetWidth(); m_ManagedDebuggerToggle.OnGUI(managedDebuggerTogglePosX, 0); GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { float progressBarHorizontalPosition = position.width - statusWheelWidth - m_ManagedDebuggerToggle.GetWidth(); if (AsyncProgressBar.isShowing) { progressBarHorizontalPosition -= progressBarWidth + spacing; EditorGUI.ProgressBar(new Rect(progressBarHorizontalPosition, 0, progressBarWidth, barHeight), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (showBakeMode) { GUI.Label(new Rect(progressBarHorizontalPosition - lightingBakeModeBarWidth - spacing, 0, lightingBakeModeBarWidth, barHeight), m_BakeModeString, EditorStyles.progressBarText); progressBarHorizontalPosition -= lightingBakeModeBarWidth + spacing; } if (compiling) { if (assembliesLocked) { GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_AssemblyLock.image.width, s_AssemblyLock.image.height), s_AssemblyLock, GUIStyle.none); } else { int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f); GUI.Label(new Rect(position.width - statusWheelWidth, 0, s_StatusWheel[frame].image.width, s_StatusWheel[frame].image.height), s_StatusWheel[frame], GUIStyle.none); } } if (Unsupported.IsBleedingEdgeBuild()) { var backup = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(progressBarHorizontalPosition - 310 - spacing, 0, 310, barHeight), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = backup; } else if (Unsupported.IsDeveloperMode()) { GUI.Label(new Rect(progressBarHorizontalPosition - 300 - spacing, 0, 300, barHeight), m_MiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(m_MiniMemoryOverview); } } DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
internal static GUIStyle GetStyleForErrorMode(int mode, bool isIcon, bool isSmall) { GUIStyle result; if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 3148115)) { if (isIcon) { if (isSmall) { result = ConsoleWindow.Constants.IconErrorSmallStyle; } else { result = ConsoleWindow.Constants.IconErrorStyle; } } else if (isSmall) { result = ConsoleWindow.Constants.ErrorSmallStyle; } else { result = ConsoleWindow.Constants.ErrorStyle; } } else if (ConsoleWindow.HasMode(mode, (ConsoleWindow.Mode) 4736)) { if (isIcon) { if (isSmall) { result = ConsoleWindow.Constants.IconWarningSmallStyle; } else { result = ConsoleWindow.Constants.IconWarningStyle; } } else if (isSmall) { result = ConsoleWindow.Constants.WarningSmallStyle; } else { result = ConsoleWindow.Constants.WarningStyle; } } else if (isIcon) { if (isSmall) { result = ConsoleWindow.Constants.IconLogSmallStyle; } else { result = ConsoleWindow.Constants.IconLogStyle; } } else if (isSmall) { result = ConsoleWindow.Constants.LogSmallStyle; } else { result = ConsoleWindow.Constants.LogStyle; } return(result); }
public static void SetConsoleErrorPause(bool enabled) { ConsoleWindow.SetFlag(ConsoleWindow.ConsoleFlags.ErrorPause, enabled); }
private void OnGUI() { ConsoleWindow.LoadIcons(); if (background == null) { background = "AppToolbar"; } if (EditorApplication.isPlayingOrWillChangePlaymode) { GUI.color = (Color)HostView.kPlayModeDarken; } if (Event.current.type == EventType.Repaint) { background.Draw(new Rect(0f, 0f, base.position.width, base.position.height), false, false, false, false); } bool isCompiling = EditorApplication.isCompiling; GUILayout.Space(2f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(2f); string statusText = LogEntries.GetStatusText(); if (statusText != null) { int statusMask = LogEntries.GetStatusMask(); GUIStyle statusStyleForErrorMode = ConsoleWindow.GetStatusStyleForErrorMode(statusMask); GUILayout.Label(ConsoleWindow.GetIconForErrorMode(statusMask, false), statusStyleForErrorMode, new GUILayoutOption[0]); GUILayout.Space(2f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(2f); if (isCompiling) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(GUIView.current.position.width - 52f) }; GUILayout.Label(statusText, statusStyleForErrorMode, options); } else { GUILayout.Label(statusText, statusStyleForErrorMode, new GUILayoutOption[0]); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); if (Event.current.type == EventType.MouseDown) { Event.current.Use(); LogEntries.ClickStatusBar(Event.current.clickCount); GUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { float x = base.position.width - 24f; if (AsyncProgressBar.isShowing) { x -= 188f; EditorGUI.ProgressBar(new Rect(x, 0f, 185f, 19f), AsyncProgressBar.progress, AsyncProgressBar.progressInfo); } if (isCompiling) { int index = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10f, 11.99f); GUI.Label(new Rect(base.position.width - 24f, 0f, (float)s_StatusWheel[index].image.width, (float)s_StatusWheel[index].image.height), s_StatusWheel[index], GUIStyle.none); } if (Unsupported.IsBleedingEdgeBuild()) { Color color = GUI.color; GUI.color = Color.yellow; GUI.Label(new Rect(x - 310f, 0f, 310f, 19f), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD"); GUI.color = color; } else if (Unsupported.IsDeveloperBuild()) { GUI.Label(new Rect(x - 200f, 0f, 200f, 19f), this.m_LastMiniMemoryOverview, EditorStyles.progressBarText); EditorGUIUtility.CleanCache(this.m_LastMiniMemoryOverview); } } base.DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); }
public static void ShowConsoleWindow(bool immediate) { if (ms_ConsoleWindow == null) { ms_ConsoleWindow = ScriptableObject.CreateInstance<ConsoleWindow>(); ms_ConsoleWindow.Show(immediate); ms_ConsoleWindow.Focus(); } else { ms_ConsoleWindow.Show(immediate); ms_ConsoleWindow.Focus(); } }
public static bool GetConsoleErrorPause() { return(ConsoleWindow.HasFlag(ConsoleWindow.ConsoleFlags.ErrorPause)); }
private void OnGUI() { Event current = Event.current; ConsoleWindow.LoadIcons(); GUILayout.BeginHorizontal(ConsoleWindow.Constants.Toolbar, new GUILayoutOption[0]); if (GUILayout.Button("Clear", ConsoleWindow.Constants.MiniButton, new GUILayoutOption[0])) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int count = LogEntries.GetCount(); if (this.m_ListView.totalRows != count && this.m_ListView.scrollPos.y >= (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight)) { this.m_ListView.scrollPos.y = (float)(count * 32 - this.ms_LVHeight); } EditorGUILayout.Space(); bool flag = this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse); this.SetFlag(ConsoleWindow.ConsoleFlags.Collapse, GUILayout.Toggle(flag, "Collapse", ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0])); bool flag2 = flag != this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse); if (flag2) { this.m_ListView.row = -1; this.m_ListView.scrollPos.y = (float)(LogEntries.GetCount() * 32); } this.SetFlag(ConsoleWindow.ConsoleFlags.ClearOnPlay, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.ClearOnPlay), "Clear on Play", ConsoleWindow.Constants.MiniButtonMiddle, new GUILayoutOption[0])); this.SetFlag(ConsoleWindow.ConsoleFlags.ErrorPause, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.ErrorPause), "Error Pause", ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0])); EditorGUILayout.Space(); if (this.m_DevBuild) { GUILayout.FlexibleSpace(); this.SetFlag(ConsoleWindow.ConsoleFlags.StopForAssert, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.StopForAssert), "Stop for Assert", ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0])); this.SetFlag(ConsoleWindow.ConsoleFlags.StopForError, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.StopForError), "Stop for Error", ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0])); } GUILayout.FlexibleSpace(); int num = 0; int num2 = 0; int num3 = 0; LogEntries.GetCountsByType(ref num, ref num2, ref num3); bool val = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelLog), new GUIContent((num3 > 999) ? "999+" : num3.ToString(), (num3 <= 0) ? ConsoleWindow.iconInfoMono : ConsoleWindow.iconInfoSmall), ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0]); bool val2 = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelWarning), new GUIContent((num2 > 999) ? "999+" : num2.ToString(), (num2 <= 0) ? ConsoleWindow.iconWarnMono : ConsoleWindow.iconWarnSmall), ConsoleWindow.Constants.MiniButtonMiddle, new GUILayoutOption[0]); bool val3 = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelError), new GUIContent((num > 999) ? "999+" : num.ToString(), (num <= 0) ? ConsoleWindow.iconErrorMono : ConsoleWindow.iconErrorSmall), ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0]); this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelLog, val); this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelWarning, val2); this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelError, val3); GUILayout.EndHorizontal(); this.m_ListView.totalRows = LogEntries.StartGettingEntries(); SplitterGUILayout.BeginVerticalSplit(this.spl, new GUILayoutOption[0]); EditorGUIUtility.SetIconSize(new Vector2(32f, 32f)); GUIContent gUIContent = new GUIContent(); int controlID = GUIUtility.GetControlID(FocusType.Native); try { bool flag3 = false; bool flag4 = this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse); foreach (ListViewElement listViewElement in ListViewGUI.ListView(this.m_ListView, ConsoleWindow.Constants.Box, new GUILayoutOption[0])) { if (current.type == EventType.MouseDown && current.button == 0 && listViewElement.position.Contains(current.mousePosition)) { if (current.clickCount == 2) { LogEntries.RowGotDoubleClicked(this.m_ListView.row); } flag3 = true; } if (current.type == EventType.Repaint) { int mode = 0; string text = null; LogEntries.GetFirstTwoLinesEntryTextAndModeInternal(listViewElement.row, ref mode, ref text); GUIStyle gUIStyle = (listViewElement.row % 2 != 0) ? ConsoleWindow.Constants.EvenBackground : ConsoleWindow.Constants.OddBackground; gUIStyle.Draw(listViewElement.position, false, false, this.m_ListView.row == listViewElement.row, false); gUIContent.text = text; GUIStyle styleForErrorMode = ConsoleWindow.GetStyleForErrorMode(mode); styleForErrorMode.Draw(listViewElement.position, gUIContent, controlID, this.m_ListView.row == listViewElement.row); if (flag4) { Rect position = listViewElement.position; gUIContent.text = LogEntries.GetEntryCount(listViewElement.row).ToString(CultureInfo.InvariantCulture); Vector2 vector = ConsoleWindow.Constants.CountBadge.CalcSize(gUIContent); position.xMin = position.xMax - vector.x; position.yMin += (position.yMax - position.yMin - vector.y) * 0.5f; position.x -= 5f; GUI.Label(position, gUIContent, ConsoleWindow.Constants.CountBadge); } } } if (flag3 && this.m_ListView.scrollPos.y >= (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight)) { this.m_ListView.scrollPos.y = (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight - 1); } if (this.m_ListView.totalRows == 0 || this.m_ListView.row >= this.m_ListView.totalRows || this.m_ListView.row < 0) { if (this.m_ActiveText.Length != 0) { this.SetActiveEntry(null); } } else { LogEntry logEntry = new LogEntry(); LogEntries.GetEntryInternal(this.m_ListView.row, logEntry); this.SetActiveEntry(logEntry); LogEntries.GetEntryInternal(this.m_ListView.row, logEntry); if (this.m_ListView.selectionChanged || !this.m_ActiveText.Equals(logEntry.condition)) { this.SetActiveEntry(logEntry); } } if (GUIUtility.keyboardControl == this.m_ListView.ID && current.type == EventType.KeyDown && current.keyCode == KeyCode.Return && this.m_ListView.row != 0) { LogEntries.RowGotDoubleClicked(this.m_ListView.row); Event.current.Use(); } if (current.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1) { this.ms_LVHeight = ListViewGUI.ilvState.rectHeight; } } finally { LogEntries.EndGettingEntries(); EditorGUIUtility.SetIconSize(Vector2.zero); } this.m_TextScroll = GUILayout.BeginScrollView(this.m_TextScroll, ConsoleWindow.Constants.Box); float minHeight = ConsoleWindow.Constants.MessageStyle.CalcHeight(GUIContent.Temp(this.m_ActiveText), base.position.width); EditorGUILayout.SelectableLabel(this.m_ActiveText, ConsoleWindow.Constants.MessageStyle, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(minHeight) }); GUILayout.EndScrollView(); SplitterGUILayout.EndVerticalSplit(); if ((current.type == EventType.ValidateCommand || current.type == EventType.ExecuteCommand) && current.commandName == "Copy" && this.m_ActiveText != string.Empty) { if (current.type == EventType.ExecuteCommand) { EditorGUIUtility.systemCopyBuffer = this.m_ActiveText; } current.Use(); } }
internal void OnGUI() { Event e = Event.current; LoadIcons(); 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); // Clear button and clearing options bool clearClicked = false; if (EditorGUILayout.DropDownToggle(ref clearClicked, Constants.Clear, EditorStyles.toolbarDropDownToggle)) { var clearOnPlay = HasFlag(ConsoleFlags.ClearOnPlay); var clearOnBuild = HasFlag(ConsoleFlags.ClearOnBuild); var clearOnRecompile = HasFlag(ConsoleFlags.ClearOnRecompile); GenericMenu menu = new GenericMenu(); menu.AddItem(Constants.ClearOnPlay, clearOnPlay, () => { SetFlag(ConsoleFlags.ClearOnPlay, !clearOnPlay); }); menu.AddItem(Constants.ClearOnBuild, clearOnBuild, () => { SetFlag(ConsoleFlags.ClearOnBuild, !clearOnBuild); }); menu.AddItem(Constants.ClearOnRecompile, clearOnRecompile, () => { SetFlag(ConsoleFlags.ClearOnRecompile, !clearOnRecompile); }); var rect = GUILayoutUtility.GetLastRect(); rect.y += EditorGUIUtility.singleLineHeight; menu.DropDown(rect); } if (clearClicked) { LogEntries.Clear(); GUIUtility.keyboardControl = 0; } int currCount = LogEntries.GetCount(); bool showSearchNoResultMessage = currCount == 0 && !String.IsNullOrEmpty(m_SearchText); if (m_ListView.totalRows != currCount) { // 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; } } bool wasCollapsed = HasFlag(ConsoleFlags.Collapse); SetFlag(ConsoleFlags.Collapse, GUILayout.Toggle(wasCollapsed, Constants.Collapse, Constants.MiniButton)); bool collapsedChanged = (wasCollapsed != HasFlag(ConsoleFlags.Collapse)); if (collapsedChanged) { // unselect if collapsed flag changed m_ListView.row = -1; // scroll to bottom m_ListView.scrollPos.y = LogEntries.GetCount() * RowHeight; } if (HasSpaceForExtraButtons()) { SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPause, Constants.MiniButton)); PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown, (int)(position.width - k_HasSpaceForExtraButtonsCutoff) + 80); } GUILayout.FlexibleSpace(); // Search bar if (HasSpaceForExtraButtons()) { SearchField(e); } // Flags int errorCount = 0, warningCount = 0, logCount = 0; LogEntries.GetCountsByType(ref errorCount, ref warningCount, ref logCount); EditorGUI.BeginChangeCheck(); bool setLogFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton); bool setWarningFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton); bool setErrorFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButtonRight); // Active entry index may no longer be valid if (EditorGUI.EndChangeCheck()) { SetActiveEntry(null); m_LastActiveEntryIndex = -1; } SetFlag(ConsoleFlags.LogLevelLog, setLogFlag); SetFlag(ConsoleFlags.LogLevelWarning, setWarningFlag); SetFlag(ConsoleFlags.LogLevelError, setErrorFlag); GUILayout.EndHorizontal(); if (showSearchNoResultMessage) { Rect r = new Rect(0, EditorGUI.kSingleLineHeight, ms_ConsoleWindow.position.width, ms_ConsoleWindow.position.height - EditorGUI.kSingleLineHeight); GUI.Box(r, m_ConsoleSearchNoResultMsg, Constants.ConsoleSearchNoResult); } else { // Console entries SplitterGUILayout.BeginVerticalSplit(spl); 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 = HasFlag(ConsoleFlags.Collapse); float scrollPosY = m_ListView.scrollPos.y; foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, ListViewOptions.wantsRowMultiSelection, Constants.Box)) { // Destroy latest restore entry if needed if (e.type == EventType.ScrollWheel || e.type == EventType.Used) { DestroyLatestRestoreEntry(); } // Make sure that scrollPos.y is always up to date after restoring last entry if (m_RestoreLatestSelection) { m_ListView.scrollPos.y = scrollPosY; } if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition)) { selectedRow = m_ListView.row; DestroyLatestRestoreEntry(); LogEntry entry = new LogEntry(); LogEntries.GetEntryInternal(m_ListView.row, entry); m_LastActiveEntryIndex = entry.globalLineIndex; if (e.clickCount == 2) { openSelectedItem = true; } } else if (e.type == EventType.Repaint) { int mode = 0; string text = null; LogEntries.GetLinesAndModeFromEntryInternal(el.row, Constants.LogStyleLineCount, ref mode, ref text); bool entryIsSelected = m_ListView.selectedItems != null && el.row < m_ListView.selectedItems.Length && m_ListView.selectedItems[el.row]; // offset value in x for icon and text var offset = Constants.LogStyleLineCount == 1 ? 4 : 8; // Draw the background GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground; s.Draw(el.position, false, false, entryIsSelected, false); // Draw the icon GUIStyle iconStyle = GetStyleForErrorMode(mode, true, Constants.LogStyleLineCount == 1); Rect iconRect = el.position; iconRect.x += offset; iconRect.y += 2; iconStyle.Draw(iconRect, false, false, entryIsSelected, false); // Draw the text tempContent.text = text; GUIStyle errorModeStyle = GetStyleForErrorMode(mode, false, Constants.LogStyleLineCount == 1); var textRect = el.position; textRect.x += offset; if (string.IsNullOrEmpty(m_SearchText)) { errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row); } else if (text != null) { //the whole text contains the searchtext, we have to know where it is int startIndex = text.IndexOf(m_SearchText, StringComparison.OrdinalIgnoreCase); if (startIndex == -1 ) // the searchtext is not in the visible text, we don't show the selection { errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row); } else // the searchtext is visible, we show the selection { int endIndex = startIndex + m_SearchText.Length; const bool isActive = false; const bool hasKeyboardFocus = true; // This ensure we draw the selection text over the label. const bool drawAsComposition = false; Color selectionColor = GUI.skin.settings.selectionColor; errorModeStyle.DrawWithTextSelection(textRect, tempContent, isActive, hasKeyboardFocus, startIndex, endIndex, drawAsComposition, selectionColor); } } if (collapsed) { Rect badgeRect = el.position; tempContent.text = LogEntries.GetEntryCount(el.row) .ToString(CultureInfo.InvariantCulture); Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent); if (Constants.CountBadge.fixedHeight > 0) { badgeSize.y = Constants.CountBadge.fixedHeight; } 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) { if (m_ActiveText.Length != 0) { SetActiveEntry(null); DestroyLatestRestoreEntry(); } } else { LogEntry entry = new LogEntry(); LogEntries.GetEntryInternal(m_ListView.row, entry); SetActiveEntry(entry); m_LastActiveEntryIndex = entry.globalLineIndex; // see if selected entry changed. if so - clear additional info LogEntries.GetEntryInternal(m_ListView.row, entry); if (m_ListView.selectionChanged || !m_ActiveText.Equals(entry.message)) { SetActiveEntry(entry); m_LastActiveEntryIndex = entry.globalLineIndex; } // If copy, get the messages from selected rows if (e.type == EventType.ExecuteCommand && e.commandName == EventCommandNames.Copy && m_ListView.selectedItems != null) { m_CopyString.Clear(); for (int rowIndex = 0; rowIndex < m_ListView.selectedItems.Length; rowIndex++) { if (m_ListView.selectedItems[rowIndex]) { LogEntries.GetEntryInternal(rowIndex, entry); m_CopyString.AppendLine(entry.message); } } } } // 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(); } } // 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.RowGotDoubleClicked(rowDoubleClicked); } // Display active text (We want word wrapped text with a vertical scrollbar) m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box); string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText, m_CallstackTextStart); float height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width); EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10)); GUILayout.EndScrollView(); SplitterGUILayout.EndVerticalSplit(); } // Copy & Paste selected item if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == EventCommandNames.Copy && m_CopyString != null) { if (e.type == EventType.ExecuteCommand) { EditorGUIUtility.systemCopyBuffer = m_CopyString.ToString(); } e.Use(); } if (!ms_ConsoleWindow) { ms_ConsoleWindow = this; } }