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;
        }
Beispiel #3
0
        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 int AddItem(UnityDebugViewerAnalysisDataTreeItem item)
        {
            int id = 0;

            lock (itemPool)
            {
                itemPool.Add(item);
                id = itemPool.Count;
            }

            return(id);
        }
        private int SortComparison(UnityDebugViewerAnalysisDataTreeItem x, UnityDebugViewerAnalysisDataTreeItem y)
        {
            var xData = x.Data as UnityDebugViewerAnalysisData;
            var yData = y.Data as UnityDebugViewerAnalysisData;

            if (xData == null || yData == null)
            {
                return(0);
            }

            return(xData.CompareTo(this.sortType, yData));
        }
        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;
                }
            }
        }
Beispiel #9
0
        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 void ResetData()
        {
            children.Clear();

            for (int i = 0; i < childrenID.Count; i++)
            {
                var item = UnityDebugViewerAnalysisDataTreeItemPool.Instance.GetItem(childrenID[i]);
                if (item == null)
                {
                    continue;
                }

                children.Add(item);
            }

            _parent = UnityDebugViewerAnalysisDataTreeItemPool.Instance.GetItem(_parentID);
        }
        private bool OnSearchChildren(UnityDebugViewerAnalysisDataTreeItem node)
        {
            if (node.Data != null)
            {
                if (string.IsNullOrEmpty(searchText))
                {
                    node.Data.isSearchedStatus = false;
                    node.Data.isVisible        = true;
                }
                else
                {
                    node.Data.isSearchedStatus = true;

                    try
                    {
                        if (Regex.IsMatch(node.Data.fullStackMessage, this.searchText))
                        {
                            node.Data.isVisible = true;
                        }
                        else
                        {
                            string str   = this.searchText.ToLower();
                            string input = node.Data.fullStackMessage.ToLower();
                            if (Regex.IsMatch(input, str))
                            {
                                node.Data.isVisible = true;
                            }
                            else
                            {
                                node.Data.isVisible = input.Contains(str);
                            }
                        }
                    }
                    catch
                    {
                        string str   = this.searchText.ToLower();
                        string input = node.Data.fullStackMessage.ToLower();
                        node.Data.isVisible = input.Contains(str);
                    }
                }
            }

            return(true);
        }
Beispiel #12
0
        public void MoveToSelectedNode(Rect panelRect, ref Vector2 scrollPos)
        {
            if (_selectedNode == null)
            {
                return;
            }

            /// make all selected node's parent expanded
            UnityDebugViewerAnalysisDataTreeItem parent = _selectedNode.Parent;

            while (parent != null && parent.Data != null)
            {
                parent.Data.isExpanded = true;
                parent = parent.Parent;
            }

            /// get selcted node's row
            DrawTreeLayout(panelRect, ref scrollPos);

            _changeSelectedRow = true;
            _selectedRow       = _selectedNode.Row;
        }
Beispiel #13
0
 protected virtual float GetRowHeight(UnityDebugViewerAnalysisDataTreeItem node)
 {
     return(1.5f * EditorGUIUtility.singleLineHeight);
 }
        private bool OnSortChildren(UnityDebugViewerAnalysisDataTreeItem node)
        {
            node.SortChildren(SortComparison);

            return(true);
        }
 public UnityDebugViewerAnalysisDataManager()
 {
     _root    = new UnityDebugViewerAnalysisDataTreeItem(null);
     sortType = AnalysisDataSortType.TotalCount;
 }
Beispiel #16
0
        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);
        }
 private bool OnResetData(UnityDebugViewerAnalysisDataTreeItem node)
 {
     node.ResetData();
     return(true);
 }
Beispiel #18
0
 public UnityDebugViewerAnalysisDataTreeView(UnityDebugViewerAnalysisDataTreeItem root)
 {
     _root              = root;
     _selectedRow       = 0;
     _changeSelectedRow = false;
 }
 public UnityDebugViewerAnalysisDataTreeItem(UnityDebugViewerAnalysisData data, UnityDebugViewerAnalysisDataTreeItem parent) : this(data)
 {
     _parent   = parent;
     _parentID = parent.id;
     _level    = _parent != null ? _parent.Level + 1 : 0;
 }
 public bool RemoveChild(UnityDebugViewerAnalysisDataTreeItem node)
 {
     return(children.Remove(node) && childrenID.Remove(node.id));
 }