//展开stack track log private void ExpandItem(int index, Rect _itemRect) { Texture2D textured; GUIStyle style; _expandedLogHistoryItemIndex = index; LogHistoryItem historyItem = _LogHistory[index]; Utils.GetImageAndStyleForHistoryItem(historyItem, DebugConsole.Instance._imageFiles, out style, out textured); style.wordWrap = true; int num = this.CalculateRowTextSpaceAvailable(_itemRect); float num2 = Mathf.Max(style.CalcHeight(new GUIContent(historyItem._LogMessage), num), GUIStyles.ConsoleRowHeight); _expandedItemHeight = (int)num2; if (!string.IsNullOrEmpty(historyItem._StackTrace)) { _expandedItemStacktrace = historyItem._StackTrace; string[] pasms = _expandedItemStacktrace.Split('\n'); float height = pasms.Length * GUIStyles.ConsoleRowHeight;// style.CalcHeight(new GUIContent(this._expandedItemStacktrace), (float)Screen.width); _expandedItemHeight += (int)(height); } else { _expandedItemStacktrace = ""; } style.wordWrap = false; ScrollToShowItem(historyItem); }
private void DrawCollapsedItemContent(Rect itemRect, LogHistoryItem historyItem) { GUIStyle style; Texture2D textured; Utils.GetImageAndStyleForHistoryItem(historyItem, DebugConsole.Instance._imageFiles, out style, out textured); //style.wordWrap = true; GUIContent content = new GUIContent(historyItem._LogMessage); Rect rect = new Rect(itemRect.x + textured.width, itemRect.y, (float)Screen.width, (float)GUIStyles.ConsoleRowHeight); GUI.Label(rect, content, style); GUI.DrawTexture( new Rect(itemRect.x, itemRect.y, textured.width, GUIStyles.ConsoleRowHeight), textured, ScaleMode.ScaleToFit ); //style.wordWrap = false; }
private void HandleMouseUpOnItem(Rect itemRect, LogHistoryItem historyItem, int index) { if (bIsDragging || Mathf.Abs(Event.current.mousePosition.y - _clickDownPosition.y) > 5f) { bIsDragging = false; } else if (Event.current.button == (int)eMouseType.MouseType_Left) { /* * 0 means left mouse button * 1 means right mouse button * 2 means middle mouse button */ if (_expandedLogHistoryItemIndex == index) { CollapseExpandedItem(); } else { ExpandItem(index, itemRect); } } Event.current.Use(); }
private void CommitLogModules() { string[] keys = Enumerable.Select(from i in DebugHelper._Modules select i, key => GetKeys(key)).ToArray(); bool[] values = Enumerable.Select(from i in DebugHelper._Modules select i, value => GetValues(value)).ToArray(); int count = Mathf.Min(keys.Length, values.Length); int index = 0; for (int i = 0; i < count; i++) { if (true == (DebugHelper._Modules[keys[i]] ? true : false)) { string _log = string.Format("Debug log modules toggled:{0}:{1}", keys[i], DebugHelper.IsModules(keys[i])); LogHistoryItem item = new LogHistoryItem(LogHistoryLogType.ConsoleInput, _log, Time.time); DebugConsole.Instance.AddItem(item); index++; } } if (0 == index) { string _log = string.Format("No Modules Selected, No one is gonna shown:)"); LogHistoryItem item = new LogHistoryItem(LogHistoryLogType.ConsoleInput, _log, Time.time); DebugConsole.Instance.AddItem(item); } }
public void AddItem(LogHistoryItem item) { _LogHistory.AddCommandLine(item); if (_LogHistory.LogCount >= 1) { _LogHistoryView.ScrollToShowItem(_LogHistory[_LogHistory.LogCount - 1]); } }
public void ScrollToShowItem(LogHistoryItem item) { int index = _LogHistory.GetIndexByItem(item); int itemTop = GetItemTop(index); int CurItemHeight = itemTop + GetItemHeight(index); //float scrollTopPos = _scrollPosition.y; float scrollBottomPos = _scrollPosition.y + _listHeight; if (CurItemHeight > scrollBottomPos) { _scrollPosition.y = Mathf.Min( Mathf.Clamp((float)itemTop, 0f, float.PositiveInfinity), Mathf.Clamp(CurItemHeight - _listHeight, 0f, float.PositiveInfinity) ); } }
private void DrawExpandedItemContent(Rect itemRect, LogHistoryItem _historyItem) { GUIStyle style; Texture2D textured; Utils.GetImageAndStyleForHistoryItem(_historyItem, DebugConsole.Instance._imageFiles, out style, out textured); GUIContent content = new GUIContent(_historyItem._LogMessage); int num = CalculateRowTextSpaceAvailable(itemRect); style.wordWrap = true; float num2 = Mathf.Max(style.CalcHeight(content, num), GUIStyles.ConsoleRowHeight); Rect rect = new Rect(itemRect.x + textured.width, itemRect.y, Screen.width, num2); GUI.Label(rect, content, style); GUI.DrawTexture( new Rect(itemRect.x, itemRect.y, textured.width, GUIStyles.ConsoleRowHeight), textured, ScaleMode.ScaleToFit ); if (!string.IsNullOrEmpty(_expandedItemStacktrace)) { rect = new Rect(itemRect.x + textured.width, itemRect.y + num2, Screen.width, _expandedItemHeight - num2); GUI.Label(rect, _expandedItemStacktrace, GUIStyles.LogHistoryItemTextAreaStyle); } style.wordWrap = false; }
private void HandleReturnKeyPressed() { if (0 == _commandInput.CompareTo("")) { return; } //保存command line到loghistoryview中 LogHistoryItem item = new LogHistoryItem(LogHistoryLogType.ConsoleInput, _commandInput, Time.time); _LogHistory.AddCommandLine(item); //判断_commandInput是否来自预设命令 CommandHandlers.HandleCommand(_commandInput); //清空command line数据 _commandInput = ""; Event.current.Use(); _LogHistoryView.ScrollToShowItem(_LogHistory[_LogHistory.LogCount - 1]); }
public static void GetImageAndStyleForHistoryItem(LogHistoryItem historyItem, ImageFilesContainer imageFiles, out GUIStyle style, out Texture2D image) { style = null; image = null; switch (historyItem._Type) { case LogHistoryLogType.Error: image = imageFiles._ErrorIcon; style = GUIStyles.ErrorLabelStyle; return; case LogHistoryLogType.Assert: image = imageFiles._AssertIcon; style = GUIStyles.AssertLabelStyle; return; case LogHistoryLogType.Warning: image = imageFiles._WarningIcon; style = GUIStyles.WarningLabelStyle; return; case LogHistoryLogType.Log: image = imageFiles._InfoIcon; style = GUIStyles.InfoLabelStyle; return; case LogHistoryLogType.Exception: image = imageFiles._ExceptionIcon; style = GUIStyles.ExceptionLabelStyle; return; case LogHistoryLogType.ConsoleInput: image = imageFiles._ConsoleInputIcon; style = GUIStyles.InfoLabelStyle; return; } throw new InvalidOperationException("unrecognized log type"); }
//绘制log项 private void DrawConsoleItem(Rect itemRect, LogHistoryItem historyItem, int index, bool inFocus) { int controlId = 0x186a0 + index; if (itemRect.Contains(Event.current.mousePosition)) { EventType type = Event.current.type; if (type == EventType.MouseUp) { HandleMouseUpOnItem(itemRect, historyItem, index); } else { //todo HandleMouseDownOnItem(controlId); } } if (Event.current.type == EventType.Repaint) { if ((index % 2) == 0) { GUIStyles.ItemAlternateBackgroundStyle.Draw(itemRect, false, false, false, false); } if (this._expandedLogHistoryItemIndex == index) { this.DrawExpandedItemContent(itemRect, historyItem); } else { this.DrawCollapsedItemContent(itemRect, historyItem); } } }
public override bool Invoke(params string[] arguments) { object obj2; // object[] asd = new object[] {30}; if (_objectRef != null) { obj2 = _getMethodInfo.Invoke(WeakObj.Target, arguments); } else { obj2 = _getMethodInfo.Invoke(null, null); } string str = string.Format("{0} : {1}", CommandName, obj2); LogHistoryItem item = new LogHistoryItem(TypeDefine.LogHistoryLogType.Log, str, Time.time); DebugConsole.Instance.AddItem(item); return(true); }