How to make conditional slider based on buttons?

Hi,
I’m putting together a simple GUI with buttons (global, height, width, depth) that determine what the slider value changes. This way I can have one slider that performs multiple transformations (global, position, etc.).

PG here

On this PG I have removed and recreated the slider… this works but is it the right approach?

I can’t get the slider onChangeObservable to change when the button is clicked…

Any ideas? Am I supposed to delete and add a slider each time a button is clicked or can I somehow delete the previous onchange event and add a new one?

Thanks.

make sure you remove the original observable:
My button slider | Babylon.js Playground (babylonjs.com)

seems to work OK that way.

2 Likes

Thanks for that! Huge help! I may end up removing and deleting the slider to easily change out the min, max, step values for each button but I like the idea of just updating the existing object.

Thanks!

1 Like