Skip to content

Abstract Class: ScriptComponent<TCamera> ​

Base class for scene scripts; construct through ScriptHost.mount.

ScriptComponent is the convenience base for the unified ComponentHandler lifecycle (docs/177 搂4.2): onStart maps to onLoad, optional onEnable/onDisable wrap the active period, and onDestroy keeps its existing meaning. The legacy single-argument onUpdate(dt) shape is preserved; hosts drive it through toComponentHandler().

Type Parameters ​

Type ParameterDefault type
TCameraunknown

Constructors ​

Constructor ​

ts
protected new ScriptComponent<TCamera>(context): ScriptComponent<TCamera>;

Parameters ​

ParameterType
contextScriptContext<TCamera>

Returns ​

ScriptComponent<TCamera>

Properties ​

PropertyModifierTypeDescription
runtimeKey?static readonlystringStable runtime class key for dynamically added scripts (docs/123 S3).
displayName?static readonlystringOptional human-readable name for dynamic mounts; pass it as runtimeScriptName.
sceneprotected readonlyScene<TCamera>Unified SDK scene facade for queries, structure changes and subscriptions.
nodeprotected readonlyNodeUnified SDK node that owns this script mount.
inputprotected readonlyInputStateShared input state.
assetsprotected readonlyScriptAssetsAsset facade for resolve/load.
signals?protected readonlyScriptSignalsNode-local signal facade for this mount (scoped provider registration).
componentRefprotected readonlystringStable componentRef of this script mount.

Accessors ​

component ​

Get Signature ​

ts
get protected component(): any;

Component handle for this script's own suity.script component. Returns null when the mount is gone.

Returns ​

any

Methods ​

provideSignal() ​

ts
protected provideSignal(signalName, fields): () => void;

Publishes script-owned state to this node's signal bus under signalName. fields maps each property name to a literal value, a () => value getter, or field options. Empty names disable; "*" is the wildcard. The returned disposer can be called early, but the handler also disposes it on unmount. Equivalent to this.node.signals.provideSignal(...).

Parameters ​

ParameterType
signalNamestring
fieldsSignalFields

Returns ​

() => void


registerSignalProvider() ​

ts
protected registerSignalProvider(provider): () => void;

Registers a full SignalProvider on this node. The handler disposes it on unmount; the returned disposer supports manual release. Equivalent to this.node.signals.registerSignalProvider(...).

Parameters ​

ParameterType
providerSignalProvider

Returns ​

() => void


log() ​

ts
protected log(...args): void;

Writes a log line to the host console / runtime output.

Parameters ​

ParameterType
...argsunknown[]

Returns ​

void


warn() ​

ts
protected warn(...args): void;

Writes a warning to the host console / runtime output.

Parameters ​

ParameterType
...argsunknown[]

Returns ​

void


error() ​

ts
protected error(...args): void;

Writes an error to the host console / runtime output.

Parameters ​

ParameterType
...argsunknown[]

Returns ​

void


toComponentHandler() ​

ts
toComponentHandler(): ComponentHandler;

Maps the legacy script hooks onto the unified ComponentHandler contract.

Hosts use this adapter instead of a second lifecycle implementation: onStart becomes onLoad, onUpdate(dt) stays single-argument, and the optional onEnable/onDisable hooks wrap the active period.

Returns ​

ComponentHandler


onStart()? ​

ts
protected onStart?(): void | Promise<void>;

Called once when the script starts; may be async (maps to onLoad).

Returns ​

void | Promise<void>


onEnable()? ​

ts
protected onEnable?(): void;

Optional: called after onStart settles and the mount is active.

Returns ​

void


onUpdate()? ​

ts
protected onUpdate?(dt): void;

Called every frame while the runtime is running; dt is in seconds.

Parameters ​

ParameterType
dtnumber

Returns ​

void


onDisable()? ​

ts
protected onDisable?(): void;

Optional: called when the mount is disabled but not yet destroyed.

Returns ​

void


onDestroy()? ​

ts
protected onDestroy?(): void;

Called when the runtime stops or this mount is removed.

Returns ​

void

Suity developer documentation · API generated by TypeDoc