In this line:
gui.add(window, A[i]);
…add()
looks on the object window
for a property with the name specified by A[i]
, which in this case evaluates to false
.
However, there's no property named false
on window
. So you need to specify properties on an object somewhere with the names you want, and then you can assign each of them the values you want to pass as the additional argument to add()
– In this case, false
would give you a checkbox in the unchecked state.
So assuming that you wanted 6 unchecked checkboxes named 1 - 6, there are a few things you could do, but they all involve adding 6 named properties to an object somewhere. Here's one way to do it using a second object to hold your controller names, which would replace your second for
loop:
for (var i=1; i<7; i++) {
controller_names[i] = A[i];
gui.add(controller_names, i, A[i]);
}
However, this may not play nicely with the save settings functionality – dat.gui seems to only be able to save settings for controls defined on the gui object itself, as explored here: Save dat.gui presets for dynamically added controls?
…in which case, you might try something more like this:
<script>
window.onload = function() {
var gui = new dat.GUI();
gui.Horizontale = 300;
gui.Vertikale = 300;
gui.A = new Array();
for (var i=1; i<7; i++) {
gui.A[i] = false;
}
gui.add(gui, 'Horizontale', 0, 600);
gui.add(gui, 'Vertikale', 0, 600);
for (var i=1; i<7; i++) {
gui.add(gui.A, i, gui.A[i]);
}
gui.remember(gui);
};
</script>