Skip to content

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.

  • Quickstart — zero to a running “Hello, world!” script in five minutes.
  • 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 via CCKWasmProjectDescriptor.
  • 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.onClick in Unity is redirected to WASM at build time.
  • Build Pipelinedotnet publish flow, generated WasmModule.csproj, on-demand tool install.
  • NetworkingSendType, per-message buffering, ping / MTU / clog checks.
  • File Storage — per-world XOR-encrypted key-value store; quotas.
  • Performance — interop cost, caching, batching, allocation hygiene.
  • API Overview
  • CVR Host Functions — everything in the CVR import 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.).

Context packs: Avatar · Prop · World.

UdonSharp Ports — five community packages and six quick snippets ported from VRChat Udon.

  • 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).