Layer
Updated
Puts the entity on a render/raycast layer so cameras and rays can include or skip it.
- Type
comp-layer- Script class
LayerComponent- 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.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
layer |
0 ≤ x ≤ 20, integer |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
Layer::change
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Switch a layer of decorationsThe H key shows or hides every decoration: the script finds the entities whose Layer component is 6 and switches them with setEnabled.
Click the scene, then press H to hide and show the flowers. 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(LayerComponent); if (component) log(component.props);}