Marks a field to trigger the onValidate callback when its value changes. Useful for reacting to property changes from the editor or at runtime.
onValidate
Your component must implement onValidate(property?: string) to receive notifications.
onValidate(property?: string)
export class MyComponent extends Behaviour { @serializable() @validate() color: Color = new Color(1, 0, 0); onValidate(property?: string) { if (property === "color") { console.log("Color changed to:", this.color); } }} Copy
export class MyComponent extends Behaviour { @serializable() @validate() color: Color = new Color(1, 0, 0); onValidate(property?: string) { if (property === "color") { console.log("Color changed to:", this.color); } }}
@validate(function(value) { console.log("Setting speed to", value);})speed: number = 1; Copy
@validate(function(value) { console.log("Setting speed to", value);})speed: number = 1;
Optional
Optional custom setter called before the value is assigned
Optional custom getter called when the value is read
Marks a field to trigger the
onValidatecallback when its value changes.Useful for reacting to property changes from the editor or at runtime.
Your component must implement
onValidate(property?: string)to receive notifications.Example: Basic usage
Example: With custom setter