Skip to content

API Function field

github-actions[bot] edited this page Dec 2, 2026 · 6 revisions

Function: field()

function field(type, options?): {
  (_value, context): void;
  <This, V>(value, context): ClassAccessorDecoratorResult<This, V>;
};

Defined in: src/engine/core/registry.ts:313

Field decorator: declare a serializable field and its type (and, for netcode, how it replicates). On an auto-accessor (@field(Number) accessor gap = 0, ADR 0667) the field is the same to scenes, the inspector and scripts, and a write that changes it calls the component's _fieldChanged(name, before, after) when it has one.

Parameters

type

FieldType

options?

FieldOptions

Returns

{ (_value, context): void; <This, V>(value, context): ClassAccessorDecoratorResult<This, V>; }

Clone this wiki locally