private void UpdateUnityConsoleOptions() { UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.Collapse, this.collapse); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelLog, this.displayLog); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelWarning, this.displayWarning); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelError, this.displayError); }
/// <summary> /// Handles incoming logs. Synchronizes only when required. /// </summary> public void Sync() { int backupFlag = UnityLogEntries.consoleFlags; UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelLog, true); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelWarning, true); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.LogLevelError, true); //UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.Collapse, true); int totalLogCount = UnityLogEntries.GetCount(); if (totalLogCount == this.lastRawEntryCount) { // Update rows with new collapse count. if (this.UpdateLog != null && (UnityLogEntries.consoleFlags & (int)ConsoleFlags.Collapse) != 0 && this.lastRawEntryCount > 0) { for (int consoleIndex = 0; consoleIndex < totalLogCount; consoleIndex++) { logEntry.collapseCount = UnityLogEntries.GetEntryCount(consoleIndex); this.UpdateLog(consoleIndex, logEntry); } Utility.RepaintEditorWindow(typeof(ModuleWindow)); this.console.Repaint(); } UnityLogEntries.consoleFlags = backupFlag; // Repaint console if an option was altered. if (backupFlag != this.lastFlags) { this.lastFlags = backupFlag; EditorPrefs.SetInt(SyncLogs.LastFlagsPrefKey, this.lastFlags); if (this.OptionAltered != null) { this.OptionAltered(); } Utility.RepaintEditorWindow(typeof(ModuleWindow)); this.console.Repaint(); } return; } if (this.lastRawEntryCount > totalLogCount) { // If collapse is disabled, it means this is a call to Clear. if ((UnityLogEntries.consoleFlags & (int)ConsoleFlags.Collapse) == 0) { this.lastRawEntryCount = 0; UnityLogEntries.consoleFlags = backupFlag; if (this.ClearLog != null) { this.ClearLog(); } return; } // Otherwise collapse has just been enabled. this.lastRawEntryCount = 0; if (this.ResetLog != null) { this.ResetLog(); } } // If collapse was just enabled, we must force the refresh of previous logs. else if ((UnityLogEntries.consoleFlags & (int)ConsoleFlags.Collapse) == 0 && this.previousCollapse == true) { this.lastRawEntryCount = 0; if (this.ResetLog != null) { this.ResetLog(); } } UnityLogEntries.StartGettingEntries(); for (int consoleIndex = this.lastRawEntryCount; consoleIndex < totalLogCount; consoleIndex++) { if (UnityLogEntries.GetEntryInternal(consoleIndex, logEntry.instance) == true) { logEntry.collapseCount = UnityLogEntries.GetEntryCount(consoleIndex); if (this.NewLog != null) { this.NewLog(consoleIndex, logEntry); } } } UnityLogEntries.EndGettingEntries(); this.lastRawEntryCount = totalLogCount; UnityLogEntries.consoleFlags = backupFlag; this.EndNewLog(); this.previousCollapse = (backupFlag & (int)ConsoleFlags.Collapse) != 0; }
/// <summary> /// Displays the top menus. /// </summary> /// <param name="r"></param> /// <returns></returns> private Rect DrawHeader(Rect r) { GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float width = r.width; // Draw Unity native features. This way is better because using style Toolbar in BeginHorizontal creates an unwanted left margin. GUI.Box(r, GUIContent.none, settings.ToolbarStyle); if (string.IsNullOrEmpty(settings.clearLabel) == false) { Utility.content.text = settings.clearLabel; Utility.content.tooltip = Utility.content.text != "Clear" ? "Clear" : string.Empty; r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; if (GUI.Button(r, Utility.content, settings.MenuButtonStyle) == true) { this.Clear(); } r.x += r.width + 5F; } EditorGUI.BeginChangeCheck(); ConsoleFlags flags = (ConsoleFlags)UnityLogEntries.consoleFlags; if (string.IsNullOrEmpty(settings.collapseLabel) == false) { Utility.content.text = settings.collapseLabel; Utility.content.tooltip = Utility.content.text != "Collapse" ? "Collapse" : string.Empty; r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; this.collapse = GUI.Toggle(r, (flags & ConsoleFlags.Collapse) != 0, Utility.content, settings.MenuButtonStyle); r.x += r.width; } if (string.IsNullOrEmpty(settings.clearOnPlayLabel) == false) { Utility.content.text = settings.clearOnPlayLabel; Utility.content.tooltip = Utility.content.text != "Clear on Play" ? "Clear on Play" : string.Empty; r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; this.clearOnPlay = GUI.Toggle(r, (flags & ConsoleFlags.ClearOnPlay) != 0, Utility.content, settings.MenuButtonStyle); r.x += r.width; } if (string.IsNullOrEmpty(settings.errorPauseLabel) == false) { Utility.content.text = settings.errorPauseLabel; Utility.content.tooltip = Utility.content.text != "Error Pause" ? "Error Pause" : string.Empty; r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; this.breakOnError = GUI.Toggle(r, (flags & ConsoleFlags.ErrorPause) != 0, Utility.content, settings.MenuButtonStyle); r.x += r.width; } Utility.content.tooltip = string.Empty; if (EditorGUI.EndChangeCheck() == true) { UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.Collapse, this.collapse); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.ClearOnPlay, this.clearOnPlay); UnityLogEntries.SetConsoleFlag((int)ConsoleFlags.ErrorPause, this.breakOnError); if (this.OptionAltered != null) { this.OptionAltered(); } Utility.RepaintConsoleWindow(); } try { if (this.AfterGUIHeaderLeftMenu != null) { this.AfterGUIHeaderLeftMenu(); } } catch (Exception ex) { this.errorPopup.exception = ex; } r.x += 5F; // Draw tabs menu. if (this.visibleModules.Length > 1) { for (int i = 0; i < this.visibleModules.Length; i++) { r = this.visibleModules[i].DrawMenu(r, this.workingModuleId); } } r.x += 5F; r.width = width - r.x; r.xMax += autoPaddingRightHeaderMenu; try { if (this.AfterGUIHeaderRightMenu != null) { r = this.AfterGUIHeaderRightMenu.Invoke(r); } } catch (Exception ex) { this.errorPopup.exception = ex; } // Display right menus. try { if (this.BeforeGUIHeaderRightMenu != null) { r = this.BeforeGUIHeaderRightMenu.Invoke(r); } } catch (Exception ex) { this.errorPopup.exception = ex; } if (r.width < 0F) { autoPaddingRightHeaderMenu += -r.width; } else if (r.width > 0F) { if (autoPaddingRightHeaderMenu > 0F) { this.Repaint(); autoPaddingRightHeaderMenu -= 1F; if (autoPaddingRightHeaderMenu < 0F) { autoPaddingRightHeaderMenu = 0F; } } } r.y += settings.menuHeight; if (this.errorPopup.exception != null) { r.x = 0F; r.width = width; r.height = this.errorPopup.boxHeight; this.errorPopup.OnGUIRect(r); r.y += r.height; } return(r); }