A toolbar row with a spacer
Updated
A script fills a row panel with a title, a UI Spacer and two buttons, so the title sits on the left and the buttons on the right; Close hides the toolbar.
Press Share to log a message, and Close to hide the toolbar. Drag outside the panel to orbit the camera, scroll to zoom.
A toolbar row with a spacer
#pragma lifecycle(startup)
// Scene: a UI Panel named 'Toolbar' whose UI Layout is a row// (flexDirection 'row', alignItems 'center').// The script fills it: a title on the left, two buttons on the right.function startup() { const toolbar = findEntity('Toolbar'); toolbar.getComponent(UILayoutComponent).setProps({ width: 480, padding: [8, 12], gap: 8 });
const title = new UILabelEntity(); title.getComponent(UILabelComponent).setProps({ text: 'Gallery', fontSize: 20 });
const spacer = new UISpacerEntity();
const share = new UIButtonEntity(); share.getComponent(UIButtonComponent).setProps({ text: 'Share', variant: 'subtle' }); share.addComponent(new SignalEmitterComponent({ signal: 'toolbar/share' }));
const close = new UIButtonEntity(); close.getComponent(UIButtonComponent).setProps({ text: 'Close' }); close.addComponent(new SignalEmitterComponent({ signal: 'toolbar/close' }));
toolbar.add(title, spacer, share, close);
on('toolbar/close', (event) => { if (event.eventType === EventType.UIButton.Press) toolbar.setEnabled(false); }); on('toolbar/share', (event) => { if (event.eventType === EventType.UIButton.Press) log('share pressed'); });}How it works
Section titled “How it works”The script is explained step by step in A toolbar row with a spacer.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
ToolbarRow.xrproj