A confirmation dialog
Updated
Reset opens a warning notification with Cancel and Reset actions in the middle of the screen; confirming shows a success notification.
Press Reset, then choose Reset or Cancel in the dialog.
A confirmation dialog
#pragma lifecycle(startup)
// Scene: a UI Button named 'Reset' with a Signal Emitter on 'ui/ask-reset'.function resetLevel() { emit('level/reset'); NotificationService.show(NotificationType.Success, { title: 'Level reset' }, { anchor: 'top' });}
function startup() { on('ui:reset', (event) => { if (event.eventType === EventType.UINotification.Action && event.data.action === 'confirm') resetLevel(); if (event.eventType === EventType.UINotification.Dismiss) log('reset cancelled'); });
on('ui/ask-reset', (event) => { if (event.eventType !== EventType.UIButton.Press) return; NotificationService.show( NotificationType.Warning, { title: 'Reset the level?', text: 'Every object goes back to where it started.', actions: [ { id: 'cancel', text: 'Cancel', variant: 'subtle' }, { id: 'confirm', text: 'Reset', backgroundColor: '#b91c1c' }, ], }, { anchor: 'center', id: 'reset', duration: Infinity, dismissable: true, signal: 'ui:reset' }, ); });}How it works
Section titled “How it works”The script is explained step by step in A confirmation dialog.
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.
ConfirmReset.xrproj