#how to set font color via code?

1 messages · Page 1 of 1 (latest)

pearl gulch
#

hi! i'm trying to set the color of the text of a label node via code, but i'm a bit lost. this is the code i'm using for the setting of the color: first, these are the relevant vars at the top of my script.

@onready var prompt: Label = $MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/Prompt
var color_enabled := Color(1.0, 1.0, 1.0)
var color_disabled := Color(0.792, 0.792, 0.792)

antd then this is the line of code i'm calling to change the color inside another function (i already made sure it's working)

prompt.set("theme_override_colors/font_color") = color_disabled

and lastly, this is a screenshot of the error i'm getting:
any help is appreciated! 🙂

tough chasm
#

If you just want the text color to change I think using self_modulate would be better
Or [color] tags with RichTextLabels if you want certain blocks of text to be of certain color

warm beacon
#

your syntax is wrong, i believe you have to either use the "property map" syntax :
prompt["theme_override_colors/font_color"] = color_disabled

if use the getter/setter method syntax :
prompt.set("theme_override_colors/font_color", color_disabled)