extends Control
class_name DrawThing
func _draw():
var dest = Vector2(rect_position.x + 100, rect_position.y + 100)
draw_line(rect_position, dest, Color.white, 5.0)
pass
If I attach DrawThing to a Control in the scene, it'll draw a line. But if I add it via script:
func _ready():
var draw1 = DrawThing.new()
$NodeGrid/Control/Links.add_child(draw1)
draw1.rect_position = Vector2()
pass
It won't draw anything. What am I missing?
Having DrawThing extend Node2D solves the issue, but I really wanted to make it work with Control.