Assigning a theme override through code does not work

Godot Version

4.2.1

Question

Here is the structure of the code (simple):
Screenshot 2024-05-07 at 10.33.26

I am trying to assign a modified StyleBoxFlat style property to the ‘Color’ panel in the structure, but no matter what i try, it doesn’t work

This is simplified version of what i am trying to do and what methods i already tried

extends Control

func _ready():
	var style_box = StyleBoxFlat.new()
	style_box.bg_color = Color8(255, 209, 0, 255)  # make background yellow
	$Color.set_theme(style_box)  # doesn't work
	$Color.add_theme_stylebox_override("styles", style_box)  # does not work as well

as you can see, i tried only two methods i found on the other help posts, but they both do not work, the panel still remains that semi-transparent black rectangle.
How do i assign a StyleBox to panel through code?

var new_style=StyleBoxFlat.new()
new_style.bg_color = Color8(255, 209, 0, 255)
$Color.add_theme_stylebox_override("panel",new_style)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.