Enabling Unity Ads

Learning how to Monetize your game with Google and apple Ads.

Simon Truong
3 min readJan 7, 2022

--

Now that we have a clear foundation for our game, it is time to create a method to allow our game make some money. This is usually through Ads that the player needs to watch for a few seconds before they are rewarded with some kind of in game currency. For this scenario we will be rewarding the players with 100 gems every time they watch an Ad.

Getting Started:

To get started with Unity Ads, we first need to activate it within the Unity Services. Select Window > General > Services to show the Services Menu. Unity will then ask you to sign in and select a Project ID and a project Organization. If you haven’t done so yet, Unity will give you an step by step tutorial in creating a new Organization that will house all of your created games.

Then we are going to select Ads, and toggle on the ability. There will be a second prompt asking if this app/game is targeted towards children under the age of 13, we are going to select “No”.

Finally once we have the proper settings, we will be greeted with an menu that looks like this.

We are going to turn on “Test Mode” to allow Unity to simulate Unity Ads within our Unity Editor.

Creating the watch Ad scenario:

As mentioned above we want the player to gain 100 gems when the player watches the ad. We are going to create this function within our Store UI where the player actually needs the gems to buy items.

Just like with all the other UI elements, I created a new button that basically has the text “Watch Ad for 100 Gems”. Then within Unity, I created a new button component to house the new button image.

I placed the button within the top right corner of the Shop UI.

Scripting The Unity Ad Button:

Now that we have our button and also set up our Unity Ads profile, It is time to link the two objects together via scripting.

First we are going to create a new C# script called “Ads Manager”. Then we are going to create a new empty game object within the Hierarchy that will contain our Ads Manager script.

Dragging and dropping the new Ads Manager script into the empty game object.

Inside the script, we are going to basically create a public method that can be accessed by the Shop UI “watch Ads” button. For now we are just going to write a Debug Log that states you have toggled the Unity Ad or not.

Back in Unity we are going to select the Shop UI panel and select the watch Ad button. Within the On-click scenario we are going to drag and drop the newly created Ads Manager component into the slot and select the “Ads Rewards” public method as the condition.

Now whenever the shop UI opens and we click the Ad button, it should display the Debug Log. In the next article, we will learn how to script with the Unity Ads rewards.

--

--

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.