Fading gui

I want to fade a dialog I made. I cannot fade the color of it, that makes it really complex as it is multiple elements. I want to fade the alpha. It is in a separate gui file and collection

How do I archive this?

Have you tried doing the following:

gui.set_color(gui.get_node("nodeName"), vmath.vector4(1,1,1,1))

and changing the alpha channel (the last one) to whatever value you wish to have? This can, of course, also be animated using a timer to get a fade effect.

There’s an easier way:

gui.animate(node, gui.PROP_COLOR, vmath.vector3(1,1,1,0), gui.EASING_LINEAR, duration)
2 Likes

All of those really on knowing the color. And I have a box insite the box I want to fade, in a different color, so it’s not really color I want to fade right?

Also is there a way to define colors and stings that I can use for both guidelines colors and text?

Ah, ok, so it’s a colored box node without a texture? You can get the color before fading (and alpha will be inherited by child nodes unless you’ve explicitly unchecked that box):

local color = gui.get_color(node)
color.w = 0
gui.animate(node, gui.PROP_COLOR, color, gui.EASING_LINEAR, duration)
2 Likes

Will this effect things inside the box to? Like text?

It depends on if Inherit Alpha is checked or not:

Ah. So alpha is somehow linked to color?

Well, yes, it’s the fourth component of RGBA (Red, Green, Red, Alpha).

If you assign a texture to a gui node and leave the color as 1,1,1,1 it means that the image will be displayed with the color values of the image. Set a color of 0,1,1,1 and you’ll eliminate all the red from the image while if you set the color to 1,1,1,0 you set it to completely transparent.

If it’s a box node without a texture the color value decides the actual color of the node, where 1,1,1,1 means white and fully opaque. 1,1,1,0 means white but completely transparent.

2 Likes