Hey all,
Before I build this from scratch, I know PlayCanvas uses this all the time. Is there an implementation of this toggle button floating around anywhere?
Thanks in advance
Hey all,
Before I build this from scratch, I know PlayCanvas uses this all the time. Is there an implementation of this toggle button floating around anywhere?
Thanks in advance
Under the hood, PlayCanvas uses the UI component library PCUI. I believe the implementation for that toggle button is the BooleanInput. Demo’d here.
I’m not sure it’s native to the library but if you look for it in editor.js of the Editor, you could ‘borrow’ the code
This seems to be the code the editor.js
script uses for that kind of toggles:
case 'checkbox':
if (args.enum) {
field = new ui.SelectField({
options: args.enum,
type: 'boolean'
});
field.flexGrow = 1;
} else {
field = new ui.Checkbox();
}
field.value = args.value || 0;
field.class.add('tick');
linkField();
panel.append(field);
break;
Thanks everyone for the leads. Very helpful.