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.
CrazyAds folder exposes a
CrazyAds class that is available anywhere in your code. Import it with
using CrazyGames; or prefix the usage with
Playing an Advertisement
Displaying an advertisement is done with a single line of code:
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:
transform.Translate(pushForce * Time.fixedDeltaTime);
if (transform.position.y < -20)
print("Player Died! Starting Ad Break!");
// Start playing an ad
print("Ad Finished! Respawning player!");
transform.position = startPos;
rb.velocity = Vector3.zero;
print("Ad has not been displayed");
AdError callback is also triggered if the ad is not filled.
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.
beginAdBreak() shows a midgame advertisement. If you want to display a rewarded ad you should call
beginAdBreakRewarded() on the same principle.
If you don't specify an errorCallback the successCallback will be called even if an error happened.
You can use the code below to detect if the user has an adblocker.
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.
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.