Layer settings
Updated
Layer definitions belong to the project: every scene of the project shares them. This page explains each setting and when it applies.
Before you start
Section titled “Before you start”- You know which layers exist. See Layers.
- You edit these settings in XR Creator’s Layers panel and in Project Settings → Layers. See Layers in XR Creator.
The settings
Section titled “The settings”Each user layer has these settings:
| Setting | What it does |
|---|---|
| Label | Its display name, such as Props or Glass. |
| Color | A colour to recognise it by while authoring. It is only a marker: it changes nothing in the world. |
| Locked | Locks every entity on the layer, so the editor cannot pick or transform them. |
| Enabled | Enables or disables every entity on the layer. Off hides, silences and stops them. |
| Raycastable | In play, whether pointers, teleport and script rays hit the entities on the layer. |
How locked and enabled apply
Section titled “How locked and enabled apply”Locked and enabled act through the entities’ own components. When an author changes a layer’s locked or enabled, the new value is written into the Lock and Enable components of every entity on that layer at that moment, and saved with each entity. Afterwards:
- Each entity can still change its own state: unlocking one entity on a locked layer is allowed.
- An entity that joins the layer later keeps its own state.
- When an entity goes live on a locked layer it has not followed yet (its scene loads, or it is enabled after being moved while disabled), the layer locks it. An unlocked layer never unlocks anything, and a layer’s
enabledis not applied then: the entity keeps its own saved Enable.
Raycastable
Section titled “Raycastable”Raycastable applies in play only. Pointers (mouse, touch, XR controllers and hands), teleport and script rays pass through an entity on a non-raycastable layer, as if it were not there. A PhysicsRaycaster checks the layer of the entity that owns each collider, so it passes through the same layers. In the editor, every user layer can be picked.
Use it for things the player should see but never block a click: glass panes, light beams, decorative foliage in front of a button.
Rendering
Section titled “Rendering”Every camera renders every user layer, including placed cameras and XR views, whatever layer the camera’s own entity is on. Layers do not hide things from a camera: to hide an entity, disable it or set its visible to false. See Enable and visible.
Snippets
Section titled “Snippets”1. Let clicks pass through glass
Section titled “1. Let clicks pass through glass”The project defines layer 15 as Glass, not raycastable. This script moves every entity whose name starts with Glass onto it, so pointers reach the buttons behind.
#pragma lifecycle(startup)
const GLASS_LAYER = 15;
function startup() { let moved = 0; scene.entities.forEach((entity) => { if (!entity.name.startsWith('Glass')) return; entity.setLayer(GLASS_LAYER); moved += 1; }); log('Moved', moved, 'glass entities to layer', GLASS_LAYER);}How it works:
- The layer’s settings come from the project; the script only assigns entities to it.
- Raycastable applies in play, so clicks pass through the glass as soon as play starts.
- Naming the layer number with a constant makes the script easy to change.
Common mistakes
Section titled “Common mistakes”Expecting a layer to hide something from the camera
Section titled “Expecting a layer to hide something from the camera”Every camera renders every user layer. Moving an entity to another layer does not hide it.
secret.setLayer(9); // still drawnsecret.setEnabled(false); // or secret.visible = false for this session onlyTesting raycastable in the editor
Section titled “Testing raycastable in the editor”Raycastable applies only in play. In the editor every user layer can be picked, so glass on a non-raycastable layer is still selectable while authoring. Enter play to check that clicks pass through.
Treating Locked as a run-time freeze
Section titled “Treating Locked as a run-time freeze”A locked layer protects entities from the editor’s tools only. In play, scripts and physics still move them.