Lock
Updated
Editor-only flag that stops the entity from being selected or moved.
- Type
comp-lock- Script class
LockComponent- Per entity
- One
- Version
- 1.0.0
- Enable
- Always on
Read about it in Common components: what it does, how to use it from a script, and examples.
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
Lock::change
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
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.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(LockComponent); if (component) log(component.props);}