@@ -32,17 +32,20 @@ private void OnGUI()
32
32
int cellStrideX = gridSizeX + spacingX ;
33
33
int cellStrideY = gridSizeY + spacingY ;
34
34
35
- for ( int y = startOffsetY ; y + gridSizeY <= Screen . height ; y += cellStrideY )
35
+ // Loop until start of the cell is beyond screen, not end of cell
36
+ for ( int y = startOffsetY ; y < Screen . height ; y += cellStrideY )
36
37
{
37
- for ( int x = startOffsetX ; x + gridSizeX <= Screen . width ; x += cellStrideX )
38
+ for ( int x = startOffsetX ; x < Screen . width ; x += cellStrideX )
38
39
{
39
- // Left line
40
+ // Draw full box even if it goes beyond screen edges
41
+
42
+ // Left
40
43
GUI . DrawTexture ( new Rect ( x , y , 1 , gridSizeY ) , Texture2D . whiteTexture ) ;
41
- // Right line
44
+ // Right
42
45
GUI . DrawTexture ( new Rect ( x + gridSizeX - 1 , y , 1 , gridSizeY ) , Texture2D . whiteTexture ) ;
43
- // Top line
46
+ // Top
44
47
GUI . DrawTexture ( new Rect ( x , y , gridSizeX , 1 ) , Texture2D . whiteTexture ) ;
45
- // Bottom line
48
+ // Bottom
46
49
GUI . DrawTexture ( new Rect ( x , y + gridSizeY - 1 , gridSizeX , 1 ) , Texture2D . whiteTexture ) ;
47
50
}
48
51
}
0 commit comments