예제 #1
0
        public override void Draw(
            float offsetX,
            float offsetY,
            DebugPrimitiveRenderer2D renderer)
        {
            // 罫線を描く
            renderer.color = borderColor;
            // まず縦
            int   end             = _widths.Length - 1; // 最後の右端線は不要
            float x               = offsetX + localLeftX + borderWidth;
            float topY            = offsetY + localTopY;
            float halfBorderWidth = borderWidth * 0.5f;

            for (int i = 0; i < end; i++)
            {
                x += _widths[i];
                x += halfBorderWidth;                 // 線の中心までずらす
                renderer.AddVerticalLine(
                    x,
                    topY,
                    height,
                    borderWidth);
                x += halfBorderWidth;
            }
            // 次に横
            end = _heights.Length - 1;             // 最後の下端線は不要
            float y     = offsetY + localTopY + borderWidth;
            float leftX = offsetX + localLeftX;

            for (int i = 0; i < end; i++)
            {
                y += _heights[i];
                y += halfBorderWidth;                 // 線の中心までずらす
                renderer.AddHorizontalLine(
                    leftX,
                    y,
                    width,
                    borderWidth);
                y += halfBorderWidth;
            }

            y = offsetY + localTopY + borderWidth;
            for (int rowIndex = 0; rowIndex < _heights.Length; rowIndex++)
            {
                float cellHeight = _heights[rowIndex];
                x = offsetX + localLeftX + borderWidth;
                for (int colIndex = 0; colIndex < _widths.Length; colIndex++)
                {
                    float cellWidth = _widths[colIndex];
                    var   cell      = cells[rowIndex, colIndex];
                    if (string.IsNullOrEmpty(cell.text) == false)
                    {
                        DrawTextMultiLine(
                            renderer,
                            cell.text,
                            textColor,
                            _fontSize,
                            x,
                            y,
                            cellWidth,
                            cellHeight,
                            true);
                    }
                    x += cellWidth + borderWidth;
                }
                y += cellHeight + borderWidth;
            }
        }