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 Importsfoldout (near the bottom) shows an import of the WASI functionrandom_get. - The
Function Exportsfoldout (near the bottom) shows an export of a functionget_random_i64
- The
- Open
WasiDemoScript.cs.ConfigureLinkergives access to theLinkerwhich can be used to expose things to WASM.FastRandomSourceis added to the linker, this provides the requiredrandom_getimport.OnEnableuses override and callsbase.OnEnable(), if you useOnEnablein your scripts which useSimpleWasmMonoBehaviourdon't forget to do this!