How to change the color of a sprite in the GUI? (SOLVED)

Here is my setup:

  1. I have a black icon of a lock stored under sprites/lock.png
  2. The lock.png is part of my sprites.atlas
  3. In my GUI I created a box with sprites/lock.png as texture

Now I want the change the color of the sprite from black to white.

I tried it with gui.set_color(gui.get_node("lock"), vmath.vector4(1, 1, 1, 1)) (See also: GUI color) but it doesn’t do anything.

Do I need to apply a material?

1 Like

Make your icon graphic white then you can set the color to anything you need such as:

black:
gui.set_color(gui.get_node("lock"), vmath.vector4(0, 0, 0, 1))

white:
gui.set_color(gui.get_node("lock"), vmath.vector4(1, 1, 1, 1))

4 Likes

Works perfectly. Thank you, sir.

2 Likes