Skip to content

Video ads

Guidelines for Advertisements

Please be sure to read our advertisement guidelines, since your game will be rejected without any feedback if it doesn't follow them.

The CrazyAds folder exposes a CrazyAds class that is available anywhere in your code. Import it with using CrazyGames; or prefix the usage with CrazyGames.

Playing an Advertisement

Displaying an advertisement is done with a single line of code:

using CrazyGames;
CrazyAds.Instance.beginAdBreak();

// OR: CrazyGames.CrazyAds.Instance.beginAdBreak();

Info

Your game will automatically be paused when the ad is being requested, and be continued when the ad finishes playing.

You can pass functions as arguments that will be called when the ad is completed or if an error happened:

using CrazyGames;

void FixedUpdate()
{
    transform.Translate(pushForce * Time.fixedDeltaTime);
    if (transform.position.y < -20)
    {
        print("Player Died!  Starting Ad Break!");
        // Start playing an ad
        CrazyAds.Instance.beginAdBreak(Respawn, AdError);
    }
}

void Respawn()
{
    print("Ad Finished!  Respawning player!");
    transform.position = startPos;
    rb.velocity = Vector3.zero;
}

void AdError()
{
    print("Ad has not been displayed");
    Respawn();
}

The AdError callback is also triggered if the ad is not filled.

Ad Types

We support two different types of advertisements: midgame and rewarded. Midgame advertisements can happen when a user died, a level has been completed, etc. Rewarded advertisements can be requested by the user in exchange for a reward (An additional life, a retry when the user died, a bonus starting item, extra starting health, etc.). Rewarded ads should be shown when users explicitly consent to watch an advertisement. By default beginAdBreak() shows a midgame advertisement. If you want to display a rewarded ad you should call beginAdBreakRewarded() on the same principle.

using CrazyGames;

CrazyAds.Instance.beginAdBreak(successCallback, errorCallback) //Midgame ad
CrazyAds.Instance.beginAdBreakRewarded(successCallback, errorCallback) //Rewarded ad

Info

If you don't specify an errorCallback the successCallback will be called even if an error happened.

Adblock detection

You can use the code below to detect if the user has an adblocker.

CrazySDK.Instance.HasAdblock();

Info

We require games to function even when the user has an adblock. The detection is not foolproof, and it would be very frustrating for a user not running any adblock to get a non-functional game. You can block extra content, such as custom skins, or some levels, to motivate the user to turn off their adblock. Also, keep in mind that turning off the adblock usually requires a page refresh. Make sure that the progress is saved, or the user may just decide to stop playing your game.

Demo

The CrazyAds folder has a CrazyAdsDemo subfolder that contains the CrazyAdsDemo scene and its assets. This scene moves a player across a cube, falls off and dies, which calls an ad. In the editor, ads will not actually run so you will see a placeholder simulation for 3 seconds. You can explore the CrazyAdsDemoPlayer.cs code example that is managing player movements and ad displaying. You can also change between midgame and rewarded ad types in the inspector when selecting the CrazyAdsDemoPlayer game object.

Crazy ads demo player inspector