示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }