コード例 #1
0
ファイル: LogHistoryView.cs プロジェクト: matrix09/Shaders
        //绘制log列表
        private void DrawConsoleItemList(bool inFocus)
        {
            _LogHistory.GetHistoryList(out bChanged);
            if (bChanged)
            {
                _expandedLogHistoryItemIndex = -1;
            }

            //统计log数目
            int count = _LogHistory.LogCount;

            //获取scrollview列表高度
            int nListHeight = CalculateListHeight();

            //获取rect
            Rect rect = GUILayoutUtility.GetRect(0f, Screen.width, (float)nListHeight, (float)nListHeight);

            //获取列表开头item index
            int scrollFirstItem = (int)(this._scrollPosition.y / ((float)GUIStyles.ConsoleRowHeight));

            //激活扩展显示stacktrack &&
            if (_expandedLogHistoryItemIndex != -1 && scrollFirstItem > _expandedLogHistoryItemIndex)
            {
                if (_scrollPosition.y > _expandedItemHeight)
                {
                    scrollFirstItem = ((int)((_scrollPosition.y - _expandedItemHeight) / (float)GUIStyles.ConsoleRowHeight)) + 1;
                }
                else
                {
                    scrollFirstItem = _expandedLogHistoryItemIndex;
                }
            }

            int scrollEndItem = Mathf.Clamp(scrollFirstItem + (Screen.height / GUIStyles.ConsoleRowHeight), 0, count);

            //遍历数据列表
            for (int i = scrollFirstItem; i < scrollEndItem; i++)
            {
                Rect itemRect = new Rect(0f, GetItemTop(i), rect.width, GetItemHeight(i));
                //过滤log
                //if(_LogHistory.CheckFilter (_LogHistory[i]._Type))
                if (_LogHistory[i] == null)
                {
                    Debug.LogException(new System.Exception("===log is empty"));
                    break;
                }
                else
                {
                    DrawConsoleItem(
                        itemRect,
                        _LogHistory[i],
                        i,
                        false
                        );
                }
            }
        }