Monetize your Games with Reward Ads in Unity

Grinding your way through a level to accrue enough gold for that shiny new sword, used to standard practice in gaming. It can be time consuming, boring and you may end up with buyer’s remorse only to find yourself grinding it out for something else.

With Unity’s built-in ads, you can offer in-game currency by watching an ad, which in turn, allows you to earn money.
Let’s begin by adding the Advertisement package through the Package Manager:

Before you can enable the Ads service, you need to make sure that your game has a Unity Project ID. Creating one is simple. Under Edit > Project Settings > Services > Ads. Then select your organization, click Create project ID, and follow the pompts:

Now you can enable the ads and make sure to enable test mode:

Here you may find that your package needs to be updated

With your Advertisement package installed and your Project ID created, it’s time to set up the Ads Service through the Dashboard.

You can access the dashboard by Either clicking on Ads in the service window or Ads within Project settings. This will take you to an external site:

Here, you will need to click “Complete Activation” and decide if you are using a 3rd party for ads. If you are only using Unity, select “No mediation”:

In order to test your ads with devices, you want to override the test mode settings. Within the monetize section under project settings in the dashboard, scroll down to Test mode and override the test mode for each store you want to test for:

Now that we have everything set up on the dashboard side, it’s time for some scripting. Let’s start by creating an empty game object to the scene and adding a script called “AdManager”:

Unity ads require the Advertisement namespace as well as the IUnityAdsListener interface:

If you are planning on releasing to both Android and IOS, you will need to enter both Ad unit ID (placement ID) as well as the GameID for both:

In the Awake() method, we can check which platform is being used and call Advertisement.Initialize():

Before we can show an ad, we need to ensure that it is loaded in the ShowRewardedVideo() method:

Next we need to check if the ad was watched completely, skipped, or failed from within the OnUnityAdsDidFinish() method:

At this point, we are getting an error with our IUnityAdsListener interface because we haven’t fully implemented it. Let’s complete that with these 3 methods:

The last thing we need in our script is to enable and disable the listener:

Save your script and fill out the fields in the inspector. Your Ad Unit ID and Game ID for Android and IOS can be found in your advertisement dashboard:

Now we can hook up the ad to our button. First add an on OnClick event to our button. Then drag the AdManager GameObject to the empty slot and select the ShowRewardedVideo() method:

Play your game, click on your ad button, and you should see the test screen showing everything working:

Don’t forget to disable TestMode before distributing to the store




Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Debugging Docker Containers

What is a microservice catalog?

Interview | Kuleen Mehtat of Wrike

Make Laravel work seamlessly with AWS DynamoDB and SQS

Building the Next Generation Web3

Script === Shotgun: You may want to reconsider giving users automation capabilities

Cordite Network Map

Make Your Enemies Facing the Threat- Game Dev Series 114

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mike Brisson

Mike Brisson

Unity Developer

More from Medium

Benefits of Prototyping without Assets

Mastering Unity Scripting by Alan Thorn

Cover of the Mastering Unity Scripting book

Galaxy Shooter 2D — Ray Cast

Sphere Scene in Unity URP