public int CompareTo(AnalysisDataSortType sortType, UnityDebugViewerAnalysisData data) { int result = 0; switch (sortType) { case AnalysisDataSortType.TotalCount: result = this.totalCount - data.totalCount; break; case AnalysisDataSortType.LogCount: result = this.logCount - data.logCount; break; case AnalysisDataSortType.WarningCount: result = this.warningCount - data.warningCount; break; case AnalysisDataSortType.ErrorCount: result = this.errorCount - data.errorCount; break; } /// 降序排列 if (result > 0) { result = -1; } else if (result < 0) { result = 1; } return(result); }
public UnityDebugViewerAnalysisDataTreeItem AddChild(UnityDebugViewerAnalysisData value) { UnityDebugViewerAnalysisDataTreeItem node = new UnityDebugViewerAnalysisDataTreeItem(value, this); children.Add(node); childrenID.Add(node.id); return(node); }
public void Clear() { childrenID.Clear(); children.Clear(); _parent = null; _parentID = 0; _data = null; }
protected virtual bool OnGetLayoutHeight(UnityDebugViewerAnalysisDataTreeItem node) { if (UnityDebugViewerAnalysisData.IsNullOrEmpty(node.Data) || node.Data.isVisible == false) { return(true); } _height += GetRowHeight(node); return(node.Data.isExpanded); }
public UnityDebugViewerAnalysisDataTreeItem FindInChildren(UnityDebugViewerAnalysisData data) { for (int i = 0; i < ChildrenCount; ++i) { UnityDebugViewerAnalysisDataTreeItem child = children[i]; if (child.Data.Equals(data)) { return(child); } } return(null); }
public UnityDebugViewerAnalysisDataTreeItem(UnityDebugViewerAnalysisData data, UnityDebugViewerAnalysisDataTreeItem parent) : this(data) { _parent = parent; if (_parent != null) { _parentID = _parent.id; _level = _parent.Level + 1; } else { _parentID = 0; _level = 0; } }
public void AddAnalysisData(LogData log) { if (log == null) { return; } UnityDebugViewerAnalysisDataTreeItem node = _root; if (log.stackList.Count == 0) { /// 没有堆栈信息的Log,全部都合到一个节点下 UnityDebugViewerAnalysisData stackNode = new UnityDebugViewerAnalysisData(null, log.type, false); UnityDebugViewerAnalysisDataTreeItem child = node.FindInChildren(stackNode); if (child == null) { node.AddChild(stackNode); } else { var data = child.Data as UnityDebugViewerAnalysisData; if (data != null) { data.AddLogCount(stackNode); } } } else { for (int i = log.stackList.Count - 1; i >= 0; i--) { UnityDebugViewerAnalysisData stackNode = new UnityDebugViewerAnalysisData(log.stackList[i], log.type, false); UnityDebugViewerAnalysisDataTreeItem child = node.FindInChildren(stackNode); if (child == null) { child = node.AddChild(stackNode); } else { var data = child.Data as UnityDebugViewerAnalysisData; if (data != null) { data.AddLogCount(stackNode); } } node = child; } } }
protected virtual void OnDrawTreeNode(Rect rowRect, UnityDebugViewerAnalysisDataTreeItem node, bool selected, bool focus) { if (UnityDebugViewerAnalysisData.IsNullOrEmpty(node.Data) || node.Data == null) { return; } if (selected) { _rowStyle = _controlID == UnityDebugViewerWindowUtility.activeControlID ? UnityDebugViewerWindowStyleUtility.selectedTreeRowStyle : UnityDebugViewerWindowStyleUtility.inactiveTreeRowStyle; } else { _rowStyle = node.Row % 2 == 0 ? UnityDebugViewerWindowStyleUtility.oddTreeRowStyle : UnityDebugViewerWindowStyleUtility.evenTreeRowStyle; } GUI.DrawTexture(rowRect, _rowStyle.normal.background); float rowIndent = INDENT_WIDTH * node.Level; Rect indentRect = new Rect(rowIndent + rowRect.x, rowRect.y, rowRect.width, rowRect.height); if (!node.IsLeaf) { var foldOutSize = EditorStyles.foldout.CalcSize(GUIContent.none); var foldOutRect = new Rect( indentRect.x - 12, indentRect.y + rowRect.height * 0.5f - foldOutSize.y * 0.5f, 12, indentRect.height); node.Data.isExpanded = EditorGUI.Foldout(foldOutRect, node.Data.isExpanded, GUIContent.none, EditorStyles.foldout); } GUIContent labelContent = new GUIContent(node.Data.ToString()); EditorGUI.LabelField(indentRect, labelContent, _rowStyle); var columnArray = node.Data.getColumnArray(); if (columnArray == null) { return; } GUIContent[] columnGUIContentArray = new GUIContent[columnArray.Length]; for (int i = 0; i < columnArray.Length; i++) { columnGUIContentArray[i] = new GUIContent(columnArray[i]); } DrawColumn(columnGUIContentArray, _rowStyle, rowRect); }
public bool HasChild(UnityDebugViewerAnalysisData data) { return(FindInChildren(data) != null); }
public UnityDebugViewerAnalysisDataTreeItem(UnityDebugViewerAnalysisData data, UnityDebugViewerAnalysisDataTreeItem parent) : this(data) { _parent = parent; _parentID = parent.id; _level = _parent != null ? _parent.Level + 1 : 0; }
public UnityDebugViewerAnalysisDataTreeItem(UnityDebugViewerAnalysisData data) { _data = data; _level = 0; id = UnityDebugViewerAnalysisDataTreeItemPool.Instance.AddItem(this); }
public static bool IsNullOrEmpty(UnityDebugViewerAnalysisData data) { return(data == null || string.IsNullOrEmpty(data.fullStackMessage)); }
public bool Equals(UnityDebugViewerAnalysisData node) { return(node.fullStackMessage.Equals(this.fullStackMessage)); }
public override bool Equals(object obj) { UnityDebugViewerAnalysisData node = obj as UnityDebugViewerAnalysisData; return(node != null && this.Equals(node)); }
public void AddLogCount(UnityDebugViewerAnalysisData data) { this.logCount += data.logCount; this.warningCount += data.warningCount; this.errorCount += data.errorCount; }
protected virtual bool OnDrawRow(UnityDebugViewerAnalysisDataTreeItem node) { if (UnityDebugViewerAnalysisData.IsNullOrEmpty(node.Data) || node.Data.isVisible == false) { return(true); } float rowHeight = GetRowHeight(node); Rect rowRect = new Rect(0, _controlRect.y + _drawY, _controlRect.width, rowHeight); node.Row = (int)(_drawY / rowHeight); if (_changeSelectedRow && _selectedRow == node.Row) { _selectedNode = node; _changeSelectedRow = false; float showTop = _controlRect.y + _scrollPos.y + _panelRect.height; float showBottom = _controlRect.y + _scrollPos.y; float rectTop = rowRect.y + rowRect.height; float rectBottom = rowRect.y; UnityDebugViewerWindowUtility.MoveToSpecificRect(showTop, showBottom, rectTop, rectBottom, ref _scrollPos); } OnDrawTreeNode(rowRect, node, _selectedNode == node, false); EventType eventType = Event.current.GetTypeForControl(_controlID); #if UNITY_5 || UNITY_5_3_OR_NEWER if (eventType == EventType.MouseDown) #else if (eventType == EventType.mouseDown) #endif { if (rowRect.Contains(Event.current.mousePosition)) { _selectedNode = node; _selectedRow = node.Row; GUI.changed = true; UnityDebugViewerWindowUtility.activeControlID = _controlID; Event.current.Use(); } } #if UNITY_5 || UNITY_5_3_OR_NEWER else if (eventType == EventType.KeyUp) #else else if (eventType == EventType.keyUp) #endif { if (_controlID == UnityDebugViewerWindowUtility.activeControlID) { if (Event.current.keyCode == KeyCode.UpArrow) { _selectedRow = _selectedNode.Row - 1; if (_selectedRow < 0) { _selectedRow = 0; } _changeSelectedRow = true; } else if (Event.current.keyCode == KeyCode.DownArrow) { _selectedRow = _selectedNode.Row + 1; int maxRow = (int)(_controlRect.height / rowHeight) - 1; if (_selectedRow > maxRow) { _selectedRow = maxRow; } _changeSelectedRow = true; } if (_changeSelectedRow) { GUI.changed = true; Event.current.Use(); } } } _drawY += rowHeight; return(node.Data.isExpanded); }