A mute key that keeps the music in sync
Updated
M hides and shows the music entity: hidden, it keeps playing silently, so it comes back in place instead of from the start.
Click once to let the browser start the sound. Then press M to mute the music and M again to bring it back where it would be.
A mute key that keeps the music in sync
#pragma lifecycle(startup, update)
// Scene: an Audio entity "Music" (autoplay, repeat).let music;
function startup() { music = findEntity('Music');}
function update() { if (!Input.keyboard.isKeyReleased(Key.M)) return; music.visible = !music.visible; log(music.visible ? 'Sound on' : 'Sound off');}How it works
Section titled “How it works”The script is explained step by step in A mute key that keeps the music in sync.
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.
MuteKey.xrproj