How do I change the url of the source image for an image-button, using code?

Hi,

I’m trying to implement a simple thumbnail selection bar using the standard gui-editor image-button to represent each thumbnail - held in a scrollable stack.

An array called ‘envThumbnails’ will hold each thumbnail.

Each thumbnail is cloned from the original image-button, made in the gui editor and then is pushed onto the array.

The thumnail is also added to the gui thumbnailStack using addControl.

I can change some properties of each cloned thumbnail - like color = ‘black’ etc,

But, so far not the image.

I need to change the image’s source url for each thumbnail.

HERE IS THE CODE:
playground.babylonjs.com/#4RTUCB#108

You need to find the second descendant - image - of your GUI.Control instance.

Example - https://playground.babylonjs.com/#4RTUCB#109

1 Like

There are no image props on the Button you can simply access it by name: https://playground.babylonjs.com/#4RTUCB#110

ahah thanks @labris

1 Like

this!

Or just use the children array of the thumbnail

1 Like

Thanks, that’s sorted it.
Cheers.

1 Like