WASI Demo
This scene demonstrates the most usage of WASI (WebAssembly System Interface) with Wasmbox. It is located in Assets\Plugins\PlaceholderSoftware\Wasmbox\Demos
.
The Demo Object
has a WasiDemoScript
attached. The ConfigureLinker
method is used to define a random number generator which can be accessed by WASM.
- Inspect
WasiDemoWat
.- The
Function Imports
foldout (near the bottom) shows an import of the WASI functionrandom_get
. - The
Function Exports
foldout (near the bottom) shows an export of a functionget_random_i64
- The
- Open
WasiDemoScript.cs
.ConfigureLinker
gives access to theLinker
which can be used to expose things to WASM.FastRandomSource
is added to the linker, this provides the requiredrandom_get
import.OnEnable
uses override and callsbase.OnEnable()
, if you useOnEnable
in your scripts which useSimpleWasmMonoBehaviour
don't forget to do this!