示例#1
0
        private void DrawStack(Rect area, AbstractLog log)
        {
            DrawStackEmpty(area);

            // layout
            const int stackPadding = 12;
            const int stackSpace = 12;
            var       x = area.x + stackPadding; var y = area.y;
            var       w = area.width - 2 * stackPadding; var h = area.height;

            const int sampleH    = 40;
            var       stackH     = h;
            var       drawSample = log.Sample.HasValue;

            if (drawSample)
            {
                stackH -= sampleH;
            }

            // draw stack
            {
                if (_isSelectedLogDirty)
                {
                    _stackScroll.Scroll.Set(0, 0);
                }
                _stackScroll.BeginLayout(new Rect(x, y, w, stackH));
                GUILayout.Space(stackSpace);
                GUILayout.Label(log.Message, Styles.Font);
                GUILayout.Space(stackSpace);
                GUILayout.Label(log.Stacktrace, Styles.StackFont);
                GUILayout.Space(stackSpace);
                _stackScroll.EndLayout();
                y += stackH;
            }

            // draw sample
            if (drawSample)
            {
                System.Action <GUIContent, string> drawIconAndLabel = (icon, label) =>
                {
                    GUILayout.Box(icon, Styles.Icon, GUILayout.Width(_iconWidth), GUILayout.Height(sampleH));
                    GUILayout.Label(label, Styles.Font);
                    GUILayout.Space(stackSpace);
                };

                GUILayout.BeginArea(new Rect(x, y, w, sampleH));
                GUILayout.BeginHorizontal();
                var sample = log.Sample.Value;
                drawIconAndLabel(Icons.ShowTime, sample.TimeToDisplay);
                drawIconAndLabel(Icons.ShowScene, sample.Scene);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                y += sampleH;
            }
        }
示例#2
0
        private void OnGUILogRow(float width, AbstractLog log, int index, bool isSelected)
        {
            const int rightPadding = 10;

            GUIStyle backStyle = null;
            GUIStyle fontStyle = null;

            if (isSelected)
            {
                backStyle = Styles.SelectedLog;
                fontStyle = Styles.SelectedLogFont;
            }
            else
            {
                backStyle = (index % 2 == 0) ? Styles.EvenLog : Styles.OddLog;
                fontStyle = Styles.Font;
            }

            var rect = new Rect(0, 0, width, _rowHeight);

            if (UnityEngine.GUI.Button(rect, "", backStyle))
            {
                _selectedLog = index;
            }

            var rightX = width - rightPadding;

            // draw sample datas
            if (log.Sample.HasValue)
            {
                System.Action <GUIContent, string> drawIconAndLabel = (icon, text) =>
                {
                    OnGUILogRowRightToLeft(text, fontStyle, ref rightX);
                    OnGUILogRowRightToLeft(icon, Styles.Icon, ref rightX);
                };
                var sample = log.Sample.Value;
                if (_config.ShowScene)
                {
                    drawIconAndLabel(Icons.ShowScene, sample.Scene);
                }
                if (_config.ShowTime)
                {
                    drawIconAndLabel(Icons.ShowTime, sample.TimeToDisplay);
                }
            }

            // draw count
            if (log.Count.HasValue)
            {
                var count = log.Count.Value;
                if (count != 0)
                {
                    OnGUILogRowRightToLeft(count.ToString(), Styles.CollapsedCountFont, ref rightX);
                }
            }

            // draw message
            {
                var msg = log.Message;
                msg = msg.Split('\n')[0];
                if (msg.Length > 256 /* magic number */)
                {
                    msg = msg.Substring(0, 256);
                }

                var icon     = Icons.ForLogType(log.Type);
                var iconRect = new Rect(0, 0, _iconWidth, _rowHeight);
                UnityEngine.GUI.Box(iconRect, icon, Styles.Icon);
                var labelRect = new Rect(_iconWidth, 0, rightX - _iconWidth, _rowHeight);
                UnityEngine.GUI.Label(labelRect, msg, fontStyle);
            }
        }