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.
- Open
AWatFile.watin a text editor, this is raw WebAssembly Text (WAT). - Inspect the
Demo Object.AWatFile.wathas been dropped into theWasm Assetproperty.Engine Configsets how the asset is compiled and run, this can usually be left at the default settings.
- Open
BasicMonoBehaviourDemoScript.cs.SimpleWasmMonoBehaviour<AWatFile>is used instead ofMonoBehaviour.AWatFileis the name of the autogenerated wrapper code (same name as the file by default).