Jump to content

Change GUI button image


AB95
 Share

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.

Link to comment
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

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

 

Link to comment
Share on other sites

  • 6 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...