A menu with a tooltip and key clicks
Updated
A File menu with three UI Menu Items, a tooltip added by a script, and an in-scene QWERTY UI Keyboard whose key presses play a click.
Rest the pointer on File to see its tooltip, press it and choose an entry: the log names it. Click the note field and press keys on the in-scene keyboard to hear them click. Drag outside the panel to orbit the camera, scroll to zoom.
A menu with a tooltip and key clicks
#pragma lifecycle(startup)
function startup() { const fileEntity = findEntity('File'); const menu = fileEntity.getComponent(UIMenuComponent); const click = findEntity('Key Click').getComponent(AudioComponent);
fileEntity.addComponent(new UITooltipComponent({ text: 'File actions', placement: 'bottom', delay: 500 }));
on('menu:file', (event) => { if (event.eventType === EventType.UIMenu.Open) log('menu opened with', menu.getItems().length, 'entries'); });
// The entries are nested below the menu: listen on each entry's own emitter. for (const item of menu.getItems()) { item.entity.addComponent(new SignalEmitterComponent({ signal: 'menu:file-item', eventFilter: ['UIMenuItem::select'] })); } on('menu:file-item', (event) => { log('chose', event.data.value); if (event.data.value === 'quit') emit('game/quit'); });
// Every keyboard entity reports on 'ui:keyboard' by default. on('ui:keyboard', (event) => { if (event.eventType === EventType.UIKeyboard.Press) click.play(); });}How it works
Section titled “How it works”The script is explained step by step in A menu with a tooltip and key clicks.
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.
FileMenu.xrproj