Skip to content

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.

  • 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.

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.

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 enabled is not applied then: the entity keeps its own saved Enable.

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.

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.

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.

GlassLayer.jx
#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.

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.

Wrong
secret.setLayer(9); // still drawn
Right
secret.setEnabled(false); // or secret.visible = false for this session only

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.

A locked layer protects entities from the editor’s tools only. In play, scripts and physics still move them.