Skip to content

Quickstart

TL;DR: Install the CCK Wasm package, add a CCKWasmProjectDescriptor to your content root, create a WasmBehaviour, log “Hello, world!”, build, and upload. If you’ve written a Unity script before, this takes under five minutes.

  • Unity version matching the CVR CCK.
  • The CVR.CCK.Wasm package imported into your project.
  • An internet connection on the first build — the pipeline downloads .NET SDK 10 preview + WASI SDK + the CCK WasmModule into %LOCALAPPDATA%/ChilloutVR/CVRBuildTools/.

C# WASM scripting is currently in closed (invite-only) testing. If you’re reading this from a published book, you’re either on the testing branch or documenting internally. The long-term plan is to replace CVR’s existing Lua scripting with this system.

Unity menu: Assets > Create > CVR Wasm Behavior (C#).

Name the file HelloWorld.cs. You get:

using UnityEngine;
using WasmScripting;
public partial class HelloWorld : WasmBehaviour
{
void Start() { }
void Update() { }
}

Three things to notice:

  • using WasmScripting; — the namespace containing WasmBehaviour and the serialization attributes.
  • : WasmBehaviour — every WASM-authorable script inherits from this, not MonoBehaviour directly.
  • partialrequired. The serialization generator emits a companion partial at build time.

Replace the body of Start():

using UnityEngine;
using WasmScripting;
public partial class HelloWorld : WasmBehaviour
{
void Start()
{
Debug.Log("Hello, world!");
}
void Update() { }
}

Debug.Log(string) is bound to CVR’s logging system. Strings go to the Unity console during Play Mode and to the CVR log in-game.

  • Drop a primitive in the scene — GameObject > 3D Object > Cube.
  • Select it.
  • In the inspector, click Add Component, search for HelloWorld, and add it.

Your root content GameObject (the avatar, prop, or world root) needs a CCKWasmProjectDescriptor.

  • Select the content root.
  • Add Component > ChilloutVR Editor > CCK Wasm Project Descriptor.
  • Leave everything default. The build processor will find your WasmBehaviour components automatically.

If your HelloWorld GameObject isn’t already a child of the content root, make it one.

  • Use the normal CCK flow (for a prop, select the CVRSpawnable and click Upload; for an avatar or world, the equivalent upload button).
  • On the first build, watch the Unity console for Installing .NET SDK and Installing WASI SDK progress bars. It takes a few minutes once.
  • On subsequent builds the pipeline is cached and completes in a few seconds.

Output lands at Assets/WasmModule.wasm, and WasmVMAnchor is added to the content root pointing at it.

When you join an instance with the built content, CVR loads the WASM module and dispatches Start. You should see:

Hello, world!

in the client log (or the Unity console if you tested in Play Mode).

That’s it — you have a running WASM script.

  • Authoring — full workflow, serialization attributes, descriptor fields.
  • Events — what else you can hook (Update, OnPlayerJoined, triggers, etc.).
  • Permissions — why certain calls throw and how to structure code around the sandbox.
  • Examples — progressive examples up to a full racing system.
  • Performance — keep your script fast as it grows.

See Troubleshooting for the common errors — the first-build download hang, error CS0103 on a type that looks imported, WasmAccessDeniedException, or a script that compiles but silently does nothing.