SDK docs
Unity WebGL
Prepare a Unity WebGL build for hosted delivery and route natural ad moments through the browser bridge.
Export checklist
- Build for WebGL with compression that works on standard HTTP hosting.
- Keep the generated Build and TemplateData folders beside index.html.
- Do not include an advertising package, provider key, or Unity WebView plugin.
Bridge the SDK
Create one small .jslib bridge and call it from your game controller. The PlayKovo SDK is the browser script in index.html; Unity only needs to forward calls to window.PlayKovoSDK.
// Assets/Plugins/WebGL/PlayKovoBridge.jslib
mergeInto(LibraryManager.library, {
PlayKovoInterstitial: function(placementPtr) {
const placement = UTF8ToString(placementPtr);
window.PlayKovoSDK?.showInterstitial({
placement,
onClose: () => SendMessage("PlayKovoBridge", "OnInterstitialClosed"),
onError: () => SendMessage("PlayKovoBridge", "OnInterstitialUnavailable"),
});
},
});
// C# game controller
[DllImport("__Internal")] private static extern void PlayKovoInterstitial(string placement);Pause and sound
PlayKovo pauses your game during ads, while the app menu is open and when the tab or app is in the background, and mutes it from the player's sound button. Forward those events into the engine. The check for isMuted skips this on SDK 1.x, so the same build runs on both versions.
// Assets/Plugins/WebGL/PlayKovoBridge.jslib (add next to PlayKovoInterstitial)
PlayKovoListen: function() {
const sdk = window.PlayKovoSDK;
if (!sdk || !sdk.isMuted) return; // SDK 1.x: nothing to do
sdk.on("pause", () => SendMessage("PlayKovoBridge", "OnPause"));
sdk.on("resume", () => SendMessage("PlayKovoBridge", "OnResume"));
sdk.on("audio", (e) => SendMessage("PlayKovoBridge", "OnAudio", e.muted ? 1 : 0));
},
PlayKovoGameplay: function(active) {
if (active) window.PlayKovoSDK?.gameplayStart?.(); else window.PlayKovoSDK?.gameplayStop?.();
},
// C#
void OnPause() { Time.timeScale = 0; AudioListener.pause = true; }
void OnResume() { Time.timeScale = 1; AudioListener.pause = false; }
void OnAudio(int muted) { AudioListener.volume = muted == 1 ? 0 : 1; }Test before review
Test the WebGL build in a hosted player, then call one placement after a completed level. The game must continue through both close and unavailable callbacks.
One SDK, every web engine