Class: LayerRegistry
Named layer registry (Unity-style). Layers are integers 0-31 used as bit positions in a 32-bit culling mask. Names are optional but improve readability — LayerRegistry.GetByName('UI') reads better than the magic number 5.
Built-in layers: 0 — Default 1 — Background 2 — World 3 — Foreground 4 — Overlay 5 — UI 6 — Debug
Layers 7-31 are free for application use. Register your own with LayerRegistry.Register.
Constructors
Constructor
ts
new LayerRegistry(): LayerRegistry;Returns
LayerRegistry
Properties
Methods
GetAll()
ts
static GetAll(): object[];Every named layer, by index.
Returns
object[]
GetByName()
ts
static GetByName(name): number;Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
number
GetName()
ts
static GetName(index): string | undefined;Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
string | undefined
MaskExcept()
ts
static MaskExcept(...layers): number;Inverse of MaskOf — all layers except the given ones.
Parameters
| Parameter | Type |
|---|---|
...layers | (string | number)[] |
Returns
number
MaskOf()
ts
static MaskOf(...layers): number;Build a culling mask from a list of layer indices or names.
Parameters
| Parameter | Type |
|---|---|
...layers | (string | number)[] |
Returns
number
Register()
ts
static Register(index, name): void;Parameters
| Parameter | Type |
|---|---|
index | number |
name | string |
Returns
void
SetName()
ts
static SetName(index, name): void;Lenient counterpart to Register for tools that own the names (the editor's project settings): replaces whatever was there, and null clears the slot. Built-ins can be renamed too — the index is what entities and masks store, not the name.
Parameters
| Parameter | Type |
|---|---|
index | number |
name | string | null |
Returns
void