Skip to content


PokiSDK - Unity

1. Initialize the SDK

In order to simplify the implementation of our SDK in Unity WebGL games, we’ve created a template and C# class that can be used instead of having to implement the Javascript SDK.

First, make sure to download the required files:

Copy the WebGLTemplates directory from the downloaded zip into your Unity game’s Assets directory.

Now, select the template in Player Settings > WebGL > Resolution and Presentation:


Our upload system rewrites the contents of index.html. Custom html must be wrapped with <!-- poki include body --> and <!-- poki include end --> Replace ‘body’ with ‘head’ to place the wrapped html in the resulting tag.

Poki Template in Player Settings

Copy the PokiUnitySDK.cs file and the Plugins folder into your project’s Assets folder so you can access the PokiSDK from your code. Now, make sure you initialize the SDK as early as possible in your application by calling PokiUnitySDK.Instance.init();.

2. Implement the gameplay events

Use the  🎮 gameplayStart()  event to describe when users are playing your game (e.g. level start and unpause).

Use the  ⛔ gameplayStop()  event to describe when users aren’t playing your game (e.g. level finish, game over, pause, quit to menu).

// first level loads, player clicks anywhere
// player is playing
// player loses round
// game over screen pops up

3. Implement commercialBreak

Commercial breaks are used to display video ads and should be triggered on natural breaks in your game. Throughout the rest of your game, we recommend you implement the  🎬 commercialBreak()  before every  🎮 gameplayStart() , i.e. whenever the user has shown an intent to continue playing.

PokiUnitySDK.Instance.commercialBreakCallBack = <function>;
// <function> is of type Function and will be triggered when the commercial break is finished.
public void commercialBreakComplete(){
    Debug.Log("Commercial break finished");
//Set the complete callback
PokiUnitySDK.Instance.commercialBreakCallBack = commercialBreakComplete;

Important information about commercialBreaks

Not every single  🎬 commercialBreak()  will trigger an ad. Poki’s system will determine when a user is ready for another ad, so feel free to signal as many commercial break opportunities as possible.

4. Implement rewardedBreak

Rewarded breaks allow for a user to choose to watch a rewarded video ad in exchange for a certain benefit in the game (e.g. more coins, etc.). When using  🎞 rewardedBreak() , please make it clear to the player beforehand that they’re about to watch an ad.

// gameplay stops (don't forget to fire gameplayStop)
// show menu
// when users selects rewarded option, trigger rewarded break
    (success) => {
        if(success) {
          // video was displayed, give reward
        else {
          // video not displayed, should probably not give reward

        // fire your function to continue to game

About the rewardedBreak timer

Rewarded breaks affect the timing of commercial breaks - When a user interacts with a rewarded break, our system’s ad timer is reset to ensure the user does not immediately see another ad.

Final steps

Disable sound and input during ads

Make sure that audio and keyboard input are disabled during commercialBreaks, so that the game doesn’t interfere with the ad:

    public void triggerRestartGame() {
        // fire your mute audio function
        // fire your disable keyboard input function
        PokiUnitySDK.Instance.commercialBreakCallBack = restartGame;

    public void restartGame(){
        // reset game here
        // fire your unmute audio function
        // fire your enable keyboard input function

Additional helpful methods

Detecting if the SDK is initialized
    PokiUnitySDK.Instance.isInitialized() // returns boolean
Detecting if ads are being blocked
    PokiUnitySDK.Instance.adsBlocked() //returns boolean

Upload and test your game in Poki for Developers

Congrats, you’ve successfully implemented the PokiSDK! Now upload your game to Poki for Developers and test it in our QA Tool. When you’re happy with the implementation, send us a review request and we’ll play the game. Feel free to contact us via Discord or if you’re stuck.

Export as WASM

Make sure to export your build as a WASM-file. This reduces file-size by +/-30% and increases parsing speed.