Change GUI button image

Recommended Posts

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.

Share this post

Link to post
Share on other sites

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

button.children[0].source = newImageUrlOrBase64String; :) 


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.