Cycle a highlight through a list with the keyboard
Updated
A script adds a fading Outline to three levers and enables one at a time; each press of Tab moves the highlight to the next lever.
Click the scene, then press Tab to move the highlight to the next lever. Drag to orbit the camera, scroll to zoom.
Cycle a highlight through a list with the keyboard
#pragma lifecycle(startup, update)
const NAMES = ['Lever A', 'Lever B', 'Lever C'];let outlines = [];let current = 0;
function startup() { outlines = NAMES.map((name) => { const entity = findEntity(name); entity.addComponent(new OutlineComponent({ color: '#a3e635', animation: 'fade', speed: 1.2 })); const outline = entity.getComponent(OutlineComponent); outline.setEnabled(false); return outline; }); outlines[current].setEnabled(true);}
function update() { if (!Input.keyboard.isKeyReleased(Key.Tab)) return; outlines[current].setEnabled(false); current = (current + 1) % outlines.length; outlines[current].setEnabled(true); emit('tutorial/focus', { name: NAMES[current] });}How it works
Section titled “How it works”The script is explained step by step in Cycle a highlight through a list with the keyboard.
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.
CycleHighlight.xrproj