Accessing and animating alpha in gui

First of all, thanks for your work and patience! You did a great engine, thank you very much!

I just don’t understand how to work with Alpha in script and i need your help.
On the attached screenshot I have a simple textNode with script and it’s not working.

function init(self)
	local easyText = gui.get_node('text_easy')
	gui.animate(easyText, 'alpha', 0, gui.EASING_OUTQUINT, 1)
end

On screenshot in the right bottom side you may see tooltip says

Availabel as ‘alpha’ in editor scripts

but how can i available it in scripts?

I searched API and found this page where it says

Alpha
The translucency of the node. The alpha value can be animated from script.
and still no examples/links on how can I do that.

I found on forum the solution - animate color instead of alpha but it’s very confusing for me. When I change opacity of color Editors Property window (screenshot) it show me color #FFFFFF and no transparence applied.

In the end I understand that

  • to change opacity through Editor property panel - use Alpha
  • to change opacity from script - use Color

Am i right or there is something that I don’t understand?

Hi @wsjscss!

You can set the color of a gui node using gui.setcolor()

Hi @Mathias_Westerdahl and thank you for reply

I want to animate opacity of the gui element and yes, you’re right - I can do it with color property in script. But there are some confusing things like tooltip in the Property panel and in documentation that says that there is a way to manipulate Alpha through the script.

1 Like

Yes, and the alpha is controlled by setting the “.w” component of the color.
Correct, there are two gui widgets for color in the editor (rgb + a), and one script function at runtime.

1 Like

Thank you for explanation.
Maybe we can do something with not working tool of selecting color opacity through Color - Custom Color - Opacity (or remove it or reflect changes on Alpha slider). And update docs line about Alpha something like this:

Alpha
The translucency of the node. The alpha value can be animated from script through color.w property

2 Likes

I don’t quite understand this part though? It’s called “Alpha” in the editor right?

The documentation suggestion is a nice addition, we’ll add it.

This widget allows you to change color opacity, but when click Save button - nothing changes. To clear this may be you can bind Opacity option from widget with Alpha slider or remove opacity option in widget. It’s confusing because it do nothing, or I’m wrong?

1 Like

I think this is a bug. I believe that the editor programmers intended to use the opacity control to set the “Alpha” value.
It should be possible, and we should add an issue for this.

Thank you @Mathias_Westerdahl for taking time and clarified this moment for me. If you don’t mind, I’ll create issue.

2 Likes

Thanks for the help yourself!