Move the dialog onto the screen
Updated
A switch moves a guide’s AI Dialog panel and AI Caption between the world, above the guide, and the screen’s corner, keeping the world placement for the way back.
Turn on Pin to screen to move the dialog panel to the bottom-right corner of the screen, and off to bring it back above the guide. Moving it needs no AI service; replies need one.
Move the dialog onto the screen
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide" with an AI Dialog and an AI Caption,// and a UI Switch "Pin to screen" with a Signal Emitter on 'settings:pin'.function startup() { const guide = findEntity('Guide'); const dialog = guide.getComponent(AIDialogComponent); const caption = guide.getComponent(AICaptionComponent);
dialog.setProps({ subtitle: 'Ask me about the collection', billboard: true, panelOffset: { x: 0, y: 0.4, z: 0 } });
on('settings:pin', (event) => { if (event.eventType !== EventType.UISwitch.Change) return; if (event.data.checked) { dialog.setProps({ positioning: 'screen', screenAnchor: 'bottom-right', insetX: 24, insetY: 24, screenScale: 0.8 }); caption.setProps({ positioning: 'screen', screenAnchor: 'bottom', insetY: 22 }); } else { dialog.setProps({ positioning: 'world' }); caption.setProps({ positioning: 'world' }); } });}How it works
Section titled “How it works”The script is explained step by step in Move the dialog onto the screen.
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.
DialogPlacement.xrproj