Runtime.Scripting (Visera.Runtime.Scripting)¶
The Scripting service embeds V8, loads a JavaScript entry script, registers native bindings, and drives OnInit (once after load) and OnTick(dt) each frame from the engine loop.
Module¶
- Export module:
Visera.Runtime.Scripting - Source:
Engine/Runtime/Source/Scripting/
Main types¶
| Type | Role |
|---|---|
FScriptingCreateInfo |
EntryScriptPath (default @assets://scripts/main.js). |
FScripting |
Owns FJavaScriptVM, FJavaScriptContext, optional input binding state; registers APIs and runs scripts. |
Construction and dependencies¶
FScripting is constructed only when FEngineCreateInfo.Scripting, Graphics, and AssetHub are all enabled. FGraphics, FAssetHub, optional FAudio, and optional FInput must outlive FScripting.
If the engine did not set MainWindow but scripting should create it from JS, pass RegisterScriptMainWindow = true. Then ResolveMainWindow() returns the FWindowCreateInfo written by visera.setMainWindow during OnInit, if any.
Lifecycle¶
- VM and context are created;
RegisterAllBindingswires Graphics, Audio, Input, and optional main-window sink. - Entry script is read via
FPlatform::ReadFileand executed in the context. - If load succeeds, global
OnInit()is invoked when defined. - Each frame,
Tick(dt)calls globalOnTick(dt)when it exists and is a function.
Submodules¶
| Doc | Module |
|---|---|
| VM | Visera.Runtime.Scripting.VM |
| Context | Visera.Runtime.Scripting.Context |
| Binding | Visera.Runtime.Scripting.Binding |
| Utils | Visera.Runtime.Scripting.Utils |
See also¶
- Architecture — engine services and
Run()order - Runtime — parent module