Implementing Unity Ads
In my last post Unity Ads (part 1) I talked about the importance of Ads, why you need them, and how you should implement them.
Step 1: Sign-Up
Make sure you have a Unity Account before you get started. You will also need a Unity Services account as well. To get one go to https://unity3d.com/services/ads to sign-up and try the free beta.
Click “Earn Money with Your Games”.
If you have never created an ad service before your dashboard will prompt you to create a new Ad Project. Do NOT create a new project. If you create a new project you will have to link the ID that is generated from your editor to this project. Instead, we will create the Ad portion of your project in Unity’s Project Editor.
Step 2: Enable Unity Services
Now that you have an account you need to open your game in unity. In the upper right hand corner of the Editor you should see the unity services tab (if you don’t see the tab, hit the cloud icon in the upper right).
Before you can enable start using Ads you need to create a Unity Project ID so you can collect your data and view it with Unity’s Analytic Dashboard.
Select “Create” to have Unity create a Unity Project ID.
Step 3: Enable Unity Ads
After you’ve turned on services and connected generated your Unity Project ID. You should see the available services that Unity provides within the Editor. Currently Analytics and Ads are the only ones available, however multiplayer options and Cloud Build are in the pipeline for future integration and use with the editor.
Turn on Ads by clicking the “Off” toggle to “On” for Ads.
To link this project with our online portal simply click “Go to Dashboard”.
The portal for your project should now open in your browser.
Step 4: Ads Integration
Now that your project is linked to Unity Ad Services, let’s get some ads in your code. There are two types of Unity Ads:
To explain these two types, I’ll start with Rewarded. Rewarded Ads keep track of whether or not the player has skipped your ad, or has completed watching the ad. This allows the developer to then reward the player after the completion of the advertisement.
Simple Ads are ads that simply run in your application without any other interaction with your application.
Unity provides some sample code for you to run in your project, which makes it really easy to plug and play with the feature.
In order to test out your ads, make sure that the “Enable Test Mode” button is selected
Also ensure that you are building to the iOS or the Android Platform.
When you run the code the ads should look like this:
And there you have it. Integrated ads in your game!