Is it possible to have a grid on the play screen?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogeriodec

Since I’m creating multiple children via code, I can only evaluate the result on the final rendered screen.
I wonder, is there any way to create a grid or other controls to evaluate, for example, if the placement of a child created in the code is correct in the final rendered output?

:bust_in_silhouette: Reply From: flurick

The least code way would be to make a png file with one cell of that grid and then set it to tile in a TextureRect (with import Filter unchecked)

Or with a bunch of code


extends Control

export var bg = Color(1,1,1)
export var fg = Color(0.6,0.5,0.5)
export var rows = 3
export var columns = 3

func _draw():
	var w = rect_size.x
	var h = rect_size.y
	var cw = w/columns #cell width
	var ch = h/rows #cell height
	draw_rect( Rect2(Vector2.ZERO,rect_size), bg)
	for row in range(1,rows, 2):
		var y = ch*row+(ch*0.5)
		draw_line( Vector2(0,y), Vector2(w,y), fg, ch )
	for column in range(1,columns, 2):
		var x = cw*column+(cw*0.5)
		draw_line( Vector2(x,0), Vector2(x,h), fg, cw )