Strange errors with draw_texture()

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

I created a custom radial container for my game, and am using draw_texture() to draw a texture at its center. Here is my script:

extends Container
class_name RadialContainer

export(int) var radius = 100 setget set_radius
export(int, 0, 180) var separation = 30 setget set_separation
export(int, 359) var orientation = 0 setget set_orientation

var sprite_index: int

func set_radius(value: int):
    radius = value

func set_separation(value: int):
    separation = value

func set_orientation(value: int):
    orientation = value

func _draw():
    draw_texture(load("res://assets/ui/dot.png"), Vector2(-3, -3))

    var children = get_children()
    var angle = (deg2rad(separation) / -2) * (children.size() - 1) - deg2rad(orientation)
    for child in children:
        child.rect_size = child.rect_min_size
        child.rect_position = Vector2(radius, 0).rotated(angle) - (child.rect_size / 2)
        angle += deg2rad(separation)

The problem is, the engine keeps throwing me errors about draw_texture() every time one of these containers is drawn, despite draw_texture() being inside a _draw() function, and also despite the fact that the game seems to draw the texture just fine anyway.

E 0:01:29.546   draw_texture: Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.
  <C++ Error>   Condition "!drawing" is true.
  <C++ Source>  scene/2d/canvas_item.cpp:812 @ draw_texture()
  <Stack Trace> @ _draw()
       @ set_radius()
       @ load_location() # (This is where I'm adding the containers from)

Does anyone know what is happening here?

:bust_in_silhouette: Reply From: spaceyjase

Don’t call _draw manually in the setters. Ideally, you mean to call update() instead. The engine will call _draw.