GUI button does not respect parent alpha after hover?

Hey team!

Working on some fading in/out modals/popups…
i notised that after hovering a button, it refuses to respect the hierarchy alpha?

It appears to happen after these functions run, nulling them sorts the issue, but i want to keep them for the hover effect!

button.pointerEnterAnimation // Reduces button's alpha by 0.1 on pointer hover.
button.pointerOutAnimation // Restores button's alpha to original state / 1 by default.

I don’t quite understand why this happens at the moment :thinking:
If you never hover the button, the alpha is 1, and stays 1, and the fade on hierarchy works and looks fine!
But if the alpha is changed at all, it starts to ignore the hierarchy alpha!

Any thoughts?

I think i found the root cause…
The bug only occurs when Control._alphaSet = true; (any changes from default Alpha)
And the control is a several times child of the main container where alpha is being use to fade the whole hierarchy (group of nested GUI elements).
In this case, it is only checking the alpha of the direct parent

context.globalAlpha = this.parent && !this.parent.renderToIntermediateTexture ? this.parent.alpha * this._alpha : this._alpha;

Do you want to create a PR so that we have @RaananW reviewing it ?

Sorry, i did not solve it, simply removed the hover effect so far.

I don’t know if it would be best to loop through all the parents or to store/cache some kind of inherited alpha
Parents alpha * that parent’s alpha etc

I had a few minutes to try something,
and now you can call me extra confused. :smile:


BABYLON.GUI.Control.AllowAlphaInheritance = true;

appears to fix the issue (i tried this yesterday, and i recall it having no effect at that time…)

1 Like