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 Parameter | Default type |
|---|---|
TCamera | unknown |
Constructors
Constructor
protected new ScriptComponent<TCamera>(context): ScriptComponent<TCamera>;Parameters
| Parameter | Type |
|---|---|
context | ScriptContext<TCamera> |
Returns
ScriptComponent<TCamera>
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
runtimeKey? | static readonly | string | Stable runtime class key for dynamically added scripts (docs/123 S3). |
displayName? | static readonly | string | Optional human-readable name for dynamic mounts; pass it as runtimeScriptName. |
scene | protected readonly | Scene<TCamera> | Unified SDK scene facade for queries, structure changes and subscriptions. |
node | protected readonly | Node | Unified SDK node that owns this script mount. |
input | protected readonly | InputState | Shared input state. |
assets | protected readonly | ScriptAssets | Asset facade for resolve/load. |
signals? | protected readonly | ScriptSignals | Node-local signal facade for this mount (scoped provider registration). |
componentRef | protected readonly | string | Stable componentRef of this script mount. |
Accessors
component
Get Signature
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()
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
| Parameter | Type |
|---|---|
signalName | string |
fields | SignalFields |
Returns
() => void
registerSignalProvider()
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
| Parameter | Type |
|---|---|
provider | SignalProvider |
Returns
() => void
log()
protected log(...args): void;Writes a log line to the host console / runtime output.
Parameters
| Parameter | Type |
|---|---|
...args | unknown[] |
Returns
void
warn()
protected warn(...args): void;Writes a warning to the host console / runtime output.
Parameters
| Parameter | Type |
|---|---|
...args | unknown[] |
Returns
void
error()
protected error(...args): void;Writes an error to the host console / runtime output.
Parameters
| Parameter | Type |
|---|---|
...args | unknown[] |
Returns
void
toComponentHandler()
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()?
protected onStart?(): void | Promise<void>;Called once when the script starts; may be async (maps to onLoad).
Returns
void | Promise<void>
onEnable()?
protected onEnable?(): void;Optional: called after onStart settles and the mount is active.
Returns
void
onUpdate()?
protected onUpdate?(dt): void;Called every frame while the runtime is running; dt is in seconds.
Parameters
| Parameter | Type |
|---|---|
dt | number |
Returns
void
onDisable()?
protected onDisable?(): void;Optional: called when the mount is disabled but not yet destroyed.
Returns
void
onDestroy()?
protected onDestroy?(): void;Called when the runtime stops or this mount is removed.
Returns
void
