Swap the image on a sign
Updated
A Decal on a sign board changes its src every five seconds; it loads each new image and restamps it.
Watch the sign change picture every five seconds. Drag to orbit the camera, scroll to zoom.
Swap the image on a sign
#pragma lifecycle(startup, dispose)
const POSTERS = [ '/example-assets/lemon-decal.png', '/example-assets/bang.png', '/example-assets/alpha.png',];let index = 0;let cancel = null;
function startup() { const decal = self.parent.getComponent(DecalComponent);
function next() { index = (index + 1) % POSTERS.length; decal.setProps({ src: POSTERS[index] }); cancel = delay(next, 5000); }
decal.setProps({ src: POSTERS[index] }); cancel = delay(next, 5000);}
function dispose() { if (cancel) cancel();}How it works
Section titled “How it works”The script is explained step by step in Swap the image on a sign.
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.
PosterRotation.xrproj