Example I have main scene and I put draw line2d in another script with name 'Draw.cs' but nothing happen on screen when I call func. I got message 'Condition "!isinsidetree()" is true. Returned: get_transform()'
My func c#
public void Square_And_Line()
{
var c = new Color(0, 0, 0, 1);
var p1 = new Vector2(this.start_pos.x, this.start_pos.y);
var p2 = new Vector2(p1.x, this.start_pos.y - this.img_height / 2);
var p3 = new Vector2(this.start_pos.x + 96, this.start_pos.y - this.img_height / 2);
var p4 = new Vector2(this.start_pos.x + 96, this.start_pos.y);
var scene = (PackedScene)GD.Load("res://node_level1.tscn");
var inst = scene.Instance();
var l1 = (Line2D)inst.GetNode("line1");
var l2 = (Line2D)inst.GetNode("line2");
var l3 = (Line2D)inst.GetNode("line3");
l1.Width = 2;
l2.Width = 2;
l3.Width = 2;
l1.AddPoint(p1);
l1.AddPoint(p2);
l2.AddPoint(p2);
l2.AddPoint(p3);
l3.AddPoint(p3);
l3.AddPoint(p4);
}