Is there a way to set a function with the index of the creating loop as a paramater?
I’m trying it like this:
for (var i = 1; i <= 3; i++) {
var topLeftButton = BABYLON.GUI.Button.CreateSimpleButton(i + "-Button", "Button " + i);
panel.addControl(topLeftButton);
topLeftButton.onPointerUpObservable.add(function () {
myFunction(i);
});
}
In this case the parameter in myFunction is 3 for every button.