Programatically add UI elements
Programatically add UI elements
I am working on a robot that will have a variable amount of joints at runtime. I would like to have a UI that has once slider per joint to control position. I know I can make a static UI that will have a fixed number of sliders. Is there a way to dynamically create UI elements at runtime depending on the number of joints I have?
Re: Programatically add UI elements
Hello,
yes, you can easily do this with the new custom UI functionality. For example:
and the function that will be called when a slider is moved:
Cheers
yes, you can easily do this with the new custom UI functionality. For example:
Code: Select all
local xml='<ui title="MyJoints">'
for i=1,#allJoints,1 do
xml=xml..'<hslider minimum="-180" maximum="180" onchange="sliderChange_callback" id="'..i..'"/>'
end
xml=xml..'</ui>'
myUi=simExtCustomUI_create(xml)
Code: Select all
sliderChange_callback=function(ui,id,value)
print("My slider "..id.."just moved!")
end