Setting apha at the click of a button

this.shuffleButton.onPointerUpObservable.add(() => {
            //this.UI.disableControls([this.UI.getControlByName("shuffleBtn")]);
            this.shuffleButton.alpha = 0.7;
            //this.shuffle();
        });

HI! Why, when I try to install alpha inside the handler for clicking on it, alpha is set for a second, then it is reset. If the same action is written in the handler of another button so that it makes changes to the transparency of the other button, everything works fine, but if the button needs to be set to transparency itself, does it not work?

A button has default events set - from Use the Babylon GUI - Babylon.js Documentation

Visual animations

By default a button will change its opacity on pointerOver and will change it scale when clicked. You can define your own animations with the following callbacks:

pointerEnterAnimation
pointerOutAnimation
pointerDownAnimation
pointerUpAnimation

Remove the effects and you should be OK.

https://www.babylonjs-playground.com/#XCPP9Y#1527

1 Like

Thank!:slight_smile: