BUTTON NODE icon Normal color change using script

Godot Version

4.3

Question

I was wondering if we can change a Button node Icon normal color using script? i have a condition like this, if the skill is lvl 2 apply theme over rides and change ICON color from green, to yellow.

if skill_levels[selected_upgrades[0]] == 2:
button. #change its Icon color to yellow.
else:
button. #set it to default

something like this. Thank you so much, ive been trying for quite sometime but i really cant make it work.

Hi there!
Ofcourse you can)

  1. You can create a THEME. And there you can set what color or texture you want by default and in needed cases.
  2. You can make node-by-node setup (like you asking). The simplest way make your button another color is using MODULATE parameter of the button.
if skill_levels[selected_upgrades[0]] == 2:
     button.modulate = color(1, 0.938, 0) # yellow
else:
     button. modulate = color(1, 1, 1) # white

Then you open ColorPicker - dont forget to swith HEX to Color values. Then choose color and copy this value to your code.

1 Like

thank you so much. :+1: this works.

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