Lock scenery against editing
Updated
The floor-standing scenery is locked with Lock components, so in the editor it cannot be picked or moved by mistake, while scripts still move it. Clicking the crate locks or unlocks it and the Lock::change event reports it.
Read the log for the locked entities, then click the crate to lock or unlock it. The pillar is locked but the script still turns it. Download the project to see the locks in XR Creator. Drag to orbit the camera, scroll to zoom.
Lock scenery against editing
#pragma lifecycle(startup, update)
let pillar;
function startup() { const locked = []; scene.entities.forEach((entity) => { if (entity.getComponent(LockComponent)?.locked) locked.push(entity.name); }); log('Locked in the editor:', locked.join(', '));
const crate = findEntity('Crate'); on('crate', (event) => { if (event.eventType === EventType.Selectable.Select) { findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again crate.setLocked(!crate.getComponent(LockComponent).locked); } if (event.eventType === EventType.Lock.Change) log(`Crate ${event.data.locked ? 'locked' : 'unlocked'}`); }); pillar = findEntity('Stone Pillar');}
function update(dt) { pillar.rotation.y += dt * 0.4; // a lock never stops a script}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.
LockedScenery.xrproj