Measure the selection
Updated
An #editor_only tool: select an entity in XR Creator and press Measure selection to log how far it is from the viewport camera.
Nothing happens in play: this script is a tool. Download the project, select a pillar in XR Creator and press Measure selection.
Measure the selection
#editor_only#pragma slot(ref=measure, type=Button, label="Measure selection", on_event=onMeasure)
function onMeasure() { const [first] = Editor.selection(); if (!first) return log('Nothing is selected.'); const distance = first.position.distanceTo(Editor.camera.position); log(first.name, 'is', distance.toFixed(1), 'm from the camera');}How it works
Section titled “How it works”The script is explained step by step in Measure the selection.
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.
MeasureSelection.xrproj