Hello. Tell me, can I make the button change on click?
Now I have a function for counting clicks, and the button changes to an even click. But I need to have three button positions like rotation, location and squeeze.
Thats my code for button:
// …
const RotAnim = scene.getAnimationGroupByName(“Rotate”);
const LocAnim = scene.getAnimationGroupByName(“Locate”);
// UI
var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI(“UI”);
var UiPanel = new BABYLON.GUI.StackPanel();
UiPanel.width = “220px”;
UiPanel.fontSize = “14px”;
UiPanel.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT;
UiPanel.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER;
advancedTexture.addControl(UiPanel);
// ..
var button = BABYLON.GUI.Button.CreateSimpleButton("but", "Locate");
button.paddingTop = "10px";
button.width = "100px";
button.height = "50px";
button.color = "white";
button.background = "green";
var clicks = 0;
button.onPointerClickObservable.add(function () {
clicks++;
if (clicks % 2 == 0) {
RotAnim.start(true, 1.0, RotAnim.from, RotAnim.to, false);
setTimeout(() => {RotAnim.stop()}, 1300);
button.children[0].text = "Locate";
} else {
LocAnim.start(true, 1.0, LocAnim.from, LocAnim.to, false);
setTimeout(() => {LocAnim.stop()}, 1300);
button.children[0].text = "Rotate";
}
});
UiPanel.addControl(button);
Ыorry for the possibly simple question (I can’t find information anywhere) and for my english