Skip to content Skip to sidebar Skip to footer

Save Dat.gui Presets For Dynamically Added Controls?

I'm dynamically adding controls to a dat.gui interface, but the 'save settings' functionality doesn't recognize them. var mygui = new dat.GUI(); mygui.remember(mygui); // standard

Solution 1:

The lines in the for loop should be:

mygui[myArray[x]] = 0.0;
var newControl = mygui2.add(mygui, myArray[x], -1, 1);

The first parameter of the add function performs two functions: it is both the source of the second parameter (the name of the control to be added, which in this case is myArray[x]) but also the destination. You can store the control names wherever you like, but if the first parameter isn't the gui, the remember() function won't know about the controls, and they won't be added to the gui's __rememberedObjects attribute or saved in the JSON object.

Post a Comment for "Save Dat.gui Presets For Dynamically Added Controls?"