AB95 Posted January 11, 2018 Share Posted January 11, 2018 Hi, sorry if this is a stupid question, for now is it possible to update a GUI Button's image after its creation? I created a button with function GUI.Button.CreateImageWithCenterTextButton(name,text,imageUrl), and I notice the third parameter is an image url, I checked with the documentation https://doc.babylonjs.com/how_to/gui but it does not mention any property name that I can use to set image url. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 11, 2018 Share Posted January 11, 2018 Hi @AB95, That button is made of an GUI image and a GUI textblock. https://github.com/BabylonJS/Babylon.js/blob/b215e22829e182a4fd6cdce8b81a9a6bf44f07cb/dist/preview release/gui/babylon.gui.js#L3823 ( image being child no. 0 ) GUI.Image has a "source" property. https://github.com/BabylonJS/Babylon.js/blob/b215e22829e182a4fd6cdce8b81a9a6bf44f07cb/dist/preview release/gui/babylon.gui.js#L3545 TL;DR: button.children[0].source = newImageUrlOrBase64String; AB95 and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
AB95 Posted January 12, 2018 Author Share Posted January 12, 2018 @aWeirdo I understand now. Thank you! Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 26, 2018 Share Posted July 26, 2018 Hi @DylanD It's hard to tell without an example, the code seems fine. Quote Link to comment Share on other sites More sharing options...
DylanD Posted July 26, 2018 Share Posted July 26, 2018 30 minutes ago, aWeirdo said: Hi @DylanD It's hard to tell without an example, the code seems fine. Hey I figured out that if I just did let button2:any; then I could change the source the way you said, very strange.... aWeirdo 1 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.