Skip to main content

Basic MonoBehaviour

This scene demonstrates the most basic usage of Wasmbox. It is located in Assets\Plugins\PlaceholderSoftware\Wasmbox\Demos.

The Demo Object has a BasicMonoBehaviourDemoScript attached. This uses the SimpleWasmMonoBehaviour to load a WASM file into memory. Once the file is loaded it calls a function which doubles a number, the output is shown at the bottom of the screen.

  1. Open AWatFile.wat in a text editor, this is raw WebAssembly Text (WAT).
  2. Inspect the Demo Object.
    • AWatFile.wat has been dropped into the Wasm Asset property.
    • Engine Config sets how the asset is compiled and run, this can usually be left at the default settings.
  3. Open BasicMonoBehaviourDemoScript.cs.
    • SimpleWasmMonoBehaviour<AWatFile> is used instead of MonoBehaviour.
    • AWatFile is the name of the autogenerated wrapper code (same name as the file by default).