Unity Monetization Rewarded Ads - 2019.3

Tutorial

·

intermediate

·

+10XP

·

15 mins

·

(14)

Unity Technologies

Unity Monetization Rewarded Ads - 2019.3

This tutorial will be a refresher on how to show a video ad within Unity, with an update on how to use ShowOptions to capture the result of displaying the ad.

Languages available:

1. Introduction

If you are using Unity 2019.2 or below, click here.


Rewarded ads are a great way to boost player engagement, letting them move beyond the free-to-play tier of your game without any financial outlay.


In this tutorial, it is assumed that you’ve already completed Getting Started with Unity Monetization, as this is primarily an extension of that. This tutorial will be a refresher on how to show a video ad within Unity, with an update on how to use ShowOptions to capture the result of displaying the ad.


2. Showing a Rewarded Video Ad

1. If you haven’t already, create or load a project and connect it to Unity Ads. Navigate to the Dashboard and find and note your project’s Game IDs.


2. In the Unity Editor, from the GameObject drop-down, select Create Empty. Name it RewardedAdDisplayObject.


3. Create and attach a new C# script called RewardedAdDisplay.


4. On line 4, type:


[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

5. On lines 7 and 8, replace the Xs with your project’s Game IDs. Beginning on line 7, type:


[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

6. In Start(), beginning on line 19, type:


[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

7. In Update(), beginning on line 29, type:


[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

8. Between the closing braces of Update() and the RewardedAdDisplay class, type:


[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

9. RewardedAdDisplay is complete (Figure 01). Save changes and return to the Unity Editor.


Figure 01: The completed RewardedAdDisplay script.

Figure 01: The completed RewardedAdDisplay script.


10. With RewardedAdDisplayObject highlighted in the Hierarchy, click the lock in the upper right-hand corner, above the Inspector. Direct your attention to the Rewarded Ad Display section of the Inspector (Figure 02).


Figure 02: The RewardedAdDisplayObject in the Inspector Window

Figure 02: The RewardedAdDisplayObject in the Inspector Window


11. Enter Play Mode. Note that the checkbox next to Ad Started is filled.


12. Click Close in the upper right of the ad display, and note that the checkbox next to Ad Completed is now also filled.


13. Exit Play Mode.


3. Conclusion

You have now completed setting up Unity Monetization Rewarded Ads, and can successfully display the rewarded video. In your game, you will want to check if AdCompleted is true and, if so, reward the player somehow.


Complete this tutorial