A tracked ticket button
Updated
A UI button with a Link opens a ticket page whose address records the room the visitor came from; pressing T opens it from a script too, and every opening is counted from the Link::open event.
Press the Tickets button, or click the view and press T: the page opens in a new tab (example.com) and the log counts the openings. Drag to orbit the camera, scroll to zoom.
A tracked ticket button
#pragma lifecycle(startup, update)
const BASE = 'https://example.com/tickets';const ROOM = 'lobby';
let link;let opened = 0;
function startup() { link = findEntity('Tickets Button').getComponent(LinkComponent); link.setProps({ url: `${BASE}?from=${ROOM}`, target: '_blank' });
on('tickets', (event) => { if (event.eventType !== EventType.Link.Open) return; opened++; log(`Tickets opened ${opened} time(s): ${event.data.url}`); });}
function update() { if (Input.keyboard.isKeyReleased(Key.T)) link.open();}How it works
Section titled “How it works”The script is explained step by step in A tracked ticket button.
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.
TicketsLink.xrproj