Nerd For Tech
Published in

Nerd For Tech

Creating Rewarded Ads in Unity

To create rewarded ads, the first thing you can do is add a button that will play the ad.

To do this I duplicated the buy button and moved it to the top right of the shop. I then changed it to have text for the shop and changed the color.

Now to enable the ads you need to open the service window by going to Window => General => Services.

Now click on the Ads button and it will open a window for you. You need to pick your organization and then you can turn on ads.

Now you need to go to the unity dashboard. Go to Monetize => Ad Units. On that screen in the project settings enable test mode for the platform you are working with.

In unity create a new empty game object with a script attached called AdsManager.

In the script create variables for the button, amount of rewarded gems, game ID, placement ID, and the player script. Also, implement the IUnityAdsListener interface. Make sure the use the UnityEngine.Advertisement namespace. Initialize the games ads in the start method along with the AddListener method.

Create a method to show the ad. In the interface, methods add the logic to allow the ad to give the reward after the ad is watched.

In unity, add the correct IDs for the game. These are found in the Ad Units section in the unity dashboard.

Make sure to set the right On Click method for the ads manager.

This will get your game playing ads.

--

--

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