Choosing a level from a list
Updated
A UI List of levels with icons and a locked row: selecting a row enables the Play button, and Play loads the scene whose id is the row’s value.
Pick a level in the list, then press Play to load its scene. Frozen Peak is disabled. Run the example again to choose another level. Drag outside the panel to orbit the camera, scroll to zoom.
Choosing a level from a list
#pragma lifecycle(startup)
function startup() { const list = findEntity('Levels').getComponent(UIListComponent); const play = findEntity('Play').getComponent(UIButtonComponent); play.setDisabled(true);
on('levels', (event) => { if (event.eventType === EventType.UIList.Select) { play.setText(`Play ${event.data.value}`); play.setDisabled(false); } });
on('levels/play', async (event) => { if (event.eventType !== EventType.UIButton.Press) return; const [level] = list.selectedValues(); if (level) await Scenes.load(level); });}How it works
Section titled “How it works”The script is explained step by step in Choosing a level from a list.
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.
LevelSelect.xrproj