BuzyGear Posted August 4, 2018 Share Posted August 4, 2018 Hey, just started to use Babylon.js, and I am wondering if there is a way to disable or modify the animation on the GUI Button when it is pressed down. Thanks. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted August 4, 2018 Share Posted August 4, 2018 Hi @BuzyGear Please see docs for buttons; https://doc.babylonjs.com/how_to/gui#button Quote Visual animations By default a button will change its opacity on pointerover and will change it's scale when clicked. You can define your own animations with the following callbacks: pointerEnterAnimation pointerOutAnimation pointerDownAnimation pointerUpAnimation and; http://doc.babylonjs.com/api/classes/babylon.gui.button#pointerdownanimation TL:DR; _this.pointerEnterAnimation = function () { _this.alpha -= 0.1; }; _this.pointerOutAnimation = function () { _this.alpha += 0.1; }; _this.pointerDownAnimation = function () { _this.scaleX -= 0.05; _this.scaleY -= 0.05; }; _this.pointerUpAnimation = function () { _this.scaleX += 0.05; _this.scaleY += 0.05; }; You can simply overwrite those functions, '_this' being your button name/variable ofcourse Have a nice saturday! Wingnut and BuzyGear 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 4, 2018 Share Posted August 4, 2018 Hi guys. Here's a PG to go with it... see lines 42-55. https://www.babylonjs-playground.com/#08KEYA#47 BuzyGear and aWeirdo 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.