Count the tables in the room
Updated
Counts the real tables an AR device detects from the XR Planes events, and emits the count on hud/tables for a HUD to show.
This one needs AR: in a headset or AR phone that labels planes, each table found raises the count. On a desktop no planes are detected.
Count the tables in the room
#pragma lifecycle(startup)
let tables = 0;
function startup() { on('room', (event) => { if (event.data.label !== 'table') return; if (event.eventType === EventType.XRPlanes.Detected) tables += 1; if (event.eventType === EventType.XRPlanes.Lost) tables -= 1; emit('hud/tables', { count: tables }); });}How it works
Section titled “How it works”The script is explained step by step in Count the tables in the room.
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.
CountTables.xrproj