Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Venex2004 |
How do I change a progress bar fill bg_color depending on the user life.
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Venex2004 |
How do I change a progress bar fill bg_color depending on the user life.
Reply From: | jgodfrey |
Something like this should work:
StyleBoxFlat
objectProgressBar
fill styleSo, in code:
func _ready():
var sb = StyleBoxFlat.new()
add_theme_stylebox_override("fill", sb)
sb.bg_color = Color("ff0000")
Note, the above script is designed to be attached directly to the ProgressBar
node. If that’s not your case, you just need a valid reference to it instead…
Once assigned, you can change the color as needed (just using something like that last line of code above).