Who is in the room
Updated
A UI Label shows the room and how many others are in it, refreshed on the Networkable’s connect, disconnect, join and leave events.
Read the label. The preview plays alone; in a published world it names the room and counts the people in it.
Who is in the room
#pragma lifecycle(startup)
let status;
function refresh() { if (!Network.connected) { status.setProps({ text: 'Playing alone' }); return; } status.setProps({ text: `Room ${Network.room}: you and ${Network.peerCount} others` });}
function startup() { status = findEntity('Status').getComponent(UILabelComponent); refresh(); on('net', (event) => { if ( event.eventType === EventType.Networkable.Connect || event.eventType === EventType.Networkable.Disconnect || event.eventType === EventType.Networkable.PeerJoin || event.eventType === EventType.Networkable.PeerLeave ) { refresh(); } });}How it works
Section titled “How it works”The script is explained step by step in Who is 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.
WhoIsHere.xrproj