how to change panel customStyle color?

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

why it did’t change color as i want?
get_node(“N”).set(“custom_styles/panel/StyleBoxTexture/modulate_color”, Color(“5cf50000”))
the color just become more darker… it should change to red

Modulate applies a color filter on top of your current texture, so if your panel has some color already, it can look weird in some cases. Try using a grayscale texture if you’re going to rely on modulate for colors.

Ev1lbl0w | 2021-08-27 13:09

my texture just white.
and i set it to gray. but i make condition, if my item is grade"rare", i want it to change to other color.

potatobanana | 2021-08-27 14:22

Can you post a screenshot of your scene?

Ev1lbl0w | 2021-08-27 14:56

enter image description here

potatobanana | 2021-08-27 15:45

Try doing this instead:

get_node("N").get("custom_styles/panel/StyleBoxTexture").modulate_color = Color("e6ff0000")

Ev1lbl0w | 2021-08-27 16:09

thanks, it work, but why it wont work before? i cant use set?

potatobanana | 2021-08-27 16:25

I’m not familiar with it, but when I tried print(get("custom_styles/panel/StyleBoxTexture/modulate_color") it printed a reference to StyleBoxTexture instead of a color, so I don’t know if you can change it with a set.

Ev1lbl0w | 2021-08-27 20:44