WASM Scripting
TL;DR: CVR runs user-written scripts as WebAssembly modules via embedded Wasmtime 34. Authors write C#, the CCK compiles it to .wasm using the .NET 10 preview NativeAOT toolchain (ILC + WASI SDK 25), and the CVR client loads one module per root content (avatar / prop / world) — not one per component. Access to Unity and CVR APIs is mediated by a three-axis permission system.
Status: the C# WASM scripting runtime is currently in closed (invite-only) testing. The long-term plan is to replace CVR’s existing Lua scripting with this system. Parts of the surface and toolchain may shift before general release.
How this section is organized
Section titled “How this section is organized”Start here
Section titled “Start here”- Quickstart — zero to a running “Hello, world!” script in five minutes.
Concepts
Section titled “Concepts”- Architecture — Wasmtime wiring; one Store per content root; 100 kHz epoch interruption.
- Runtime Lifecycle — build → load → instantiate → event dispatch → dispose.
- Authoring — subclass
WasmBehaviour, detect events by method name, attach viaCCKWasmProjectDescriptor. - Events — Unity lifecycle events, physics events, and game events a script can handle; disallowed events.
- Permissions — three-axis access check (ObjectContext × OwnerContext × ScopeContext).
- World Permissions — user-approved capabilities (identity, HTTP domains, storage quota).
- Serialization —
[WasmSerialized],[NonWasmSerialized], default behavior. - Limits — epoch deadline, storage quota, disabled WASM features.
- Unity Events Rewiring — how
Button.onClickin Unity is redirected to WASM at build time.
- Build Pipeline —
dotnet publishflow, generatedWasmModule.csproj, on-demand tool install.
- Networking —
SendType, per-message buffering, ping / MTU / clog checks. - File Storage — per-world XOR-encrypted key-value store; quotas.
Performance
Section titled “Performance”- Performance — interop cost, caching, batching, allocation hygiene.
API Reference
Section titled “API Reference”- API Overview
- CVR Host Functions — everything in the
CVRimport module (CVR_Player_*,CVR_Avatar_*,CVR_WasmUtils_*,CVR_WorldSettings_*, etc.). - UnityEngine Surface — ~280 generated bindings across UnityEngine (169), UnityEngine.AI (24), Audio (4), Rendering (54), UI (3), SceneManagement (1), EventSystems (1), Experimental.Rendering (7), TMPro (16), CVR (5).
- Not Exposed — what the sandbox explicitly denies (Input, Application, IO, Net, Reflection.Emit, etc.).
Examples
Section titled “Examples”- Examples index
- 01 — Hello World
- 02 — Click Counter
- 03 — Timed Animator
- 04 — Racing System with Laps
- 05 — File-Storage Notepad
- 06 — Networked Counter
Context packs: Avatar · Prop · World.
UdonSharp Ports — five community packages and six quick snippets ported from VRChat Udon.
On-disk sources
Section titled “On-disk sources”- Host runtime —
CVR-GameFiles/ABI_RC.Systems.WasmScripting/,CVR-GameFiles/WasmScripting/,CVR-GameFiles/WasmBinder.Links.*/,CVR-GameFiles/WasmBinder.LinksManual.UnityEngine/. - Authoring package —
CVR.CCK.Wasm/CCK/(editor),CVR.CCK.Wasm/Scripting/(attributes, enums, helpers). - Wasmtime —
CVR.CCK.Wasm/Packages/Wasmtime.34.0.2/(native + .NET wrapper).