Add the Wavedash Unity package, configure your WebGL build settings, and call the C# SDK through the JavaScript bridge.
View the SDK on GitHub Playtest the example projectInstall the SDK
Open Window > Package Manager, click + > Install package from git URL..., and paste:
https://github.com/wvdsh/sdk-unity.git
WebGL build settings
- Switch to WebGL platform in File > Build Settings
- In Player Settings, set compression to Gzip or Brotli and enable decompression fallback
- Select the Default WebGL template (not Minimal)
- Build to a folder you set as
upload_dirinwavedash.toml
The Minimal template omits the buildUrl variable in index.html. The Wavedash CLI expects that variable. Use Default.
Your index.html never runs on Wavedash
Wavedash reads your index.html to find the build files (buildUrl and the standard createUnityInstance config), but it never serves or executes the page itself. The embed constructs its own page: it creates its own canvas and calls createUnityInstance directly with a config assembled at upload time.
That means anything you add to index.html — or patch into it in a post-build step — is dead code in production:
- Custom
<script>blocks, analytics, polyfills - Loader-config tweaks (
devicePixelRatio,matchWebGLToCanvasSize,webglContextAttributes,powerPreference, …) - Canvas sizing/styling, loading bars, fullscreen buttons, error handlers
What does ship exactly as you built it:
- The build files themselves:
*.loader.js,*.framework.js,*.data,*.wasm— including any post-build patches to those files StreamingAssets/and Addressables content- Everything you do from C# at runtime
If your game needs specific loader-config behavior (for example a devicePixelRatio cap), it can't come from your template. Wavedash applies sensible defaults in its Unity entrypoint; if you need a per-game override, reach out.
This is a recurring trap for post-build scripts (and for AI coding agents): patching index.html looks like it works because the file is in the upload, but only local previews of that file will ever reflect the change. Verify template-level fixes on a Wavedash playtest link, not by opening index.html.
Use the SDK from C#
Calling Init() is required. It opts your game into Wavedash platform features and is how the SDK confirms you're set up. Call it once your game is ready to play.
void Awake()
{
Wavedash.SDK.Init(new Dictionary<string, object> { { "debug", true } });
// Init() automatically calls ReadyForEvents() unless you pass { "deferEvents", true }
// in the config. If you do defer, call Wavedash.SDK.ReadyForEvents() manually after
// your pre-game setup is complete.
}
async void LogPlayerAndScore()
{
var user = Wavedash.SDK.GetUser();
Debug.Log(user != null ? user["username"] : "no user");
var lb = await Wavedash.SDK.GetLeaderboard("high-scores");
string leaderboardId = lb != null ? (string)lb["id"] : null;
var result = await Wavedash.SDK.UploadLeaderboardScore(leaderboardId, 1500, keepBest: true);
if (result != null) Debug.Log($"rank {result["rank"]}");
}
P2P messaging
Unity exposes the same WebRTC P2P API as the JavaScript SDK. Messages are binary (byte[] or ArraySegment<byte>). Reliable messages are ordered and guaranteed; unreliable messages are faster but lossy.
// Broadcast to every peer in the lobby
Wavedash.SDK.BroadcastP2PMessage(payload, channel: 0, reliable: true);
// Send to a specific peer
Wavedash.SDK.SendP2PMessage(targetUserId, payload, channel: 0, reliable: true);
// Drain queued incoming messages once per frame
private readonly List<Wavedash.P2PMessage> _messageBuffer = new();
void Update()
{
int count = Wavedash.SDK.DrainP2PChannel(0, _messageBuffer);
for (int i = 0; i < count; i++)
{
var msg = _messageBuffer[i];
HandleMessage(msg.SenderId, msg.Channel, msg.Payload);
}
}
Wavedash.SDK.MAX_PAYLOAD_SIZE reports the maximum payload bytes for a single P2P message, derived from your P2PConfig at Init() time. See Multiplayer networking for the cross-language reference and channel conventions.
For Mirror or Netcode for GameObjects projects, the SDK ships WavedashTransport integrations under Integrations~/Mirror and Integrations~/NetcodeForGameObjects.
wavedash.toml
game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./Builds/WebGL"
[unity]
version = "6000.0.2f1"