---
title: "Display a rewarded ad with Unity Ads"
content_type: tutorial
url: "https://learn.unity.com/tutorial/unity-monetization-rewarded-ads?language=en"
language: en
difficulty: intermediate
duration_minutes: 20
unity_version:
  - "2021.3"
supported_unity_versions:
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/unity-monetization-rewarded-ads.md?language=en&version=2021.3"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/unity-monetization-rewarded-ads.md?language=en&version=2019.4"
last_updated: "2026-08-04T14:25:04.000Z"
---

# Display a rewarded ad with Unity Ads

Configure rewarded ads in Unity to grant in-game rewards for player actions and support additional monetization.

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

In this tutorial, you’ll display a rewarded video ad in a Unity project and capture the result of displaying that ad.

## 1. Overview

Rewarded ads are a great way to boost engagement, letting players move beyond the free-to-play tier of your game without any financial outlay. In this tutorial, you’ll display a rewarded video ad in a Unity project and capture the result of displaying that ad.

## 2. Before you begin

If you’re unfamiliar with Unity Ads (or need to refresh your memory), review [Get started with Unity Ads](https://learn.unity.com/tutorial/getting-started-with-unity-monetization) before you start this tutorial.

## 3. Create a script to display the ad

To create and begin the script to display 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 Hierarchy, select **Add** (**+**) and then **Create Empty**.

**3.**  Name the new GameObjected “RewardedAdDisplayObject”.

**4.**  Create a new C# script called “RewardedAdDisplay” and open it in your IDE of choice.

**5.**  On line 4, reference the Advertisements namespace:

```csharp
using UnityEngine.Advertisements;
```

**6.**  On line 6, add listeners:

```csharp
public class RewardedAdDisplay : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
```

**7.**  Beginning on line 8, add:

```csharp
public string myGameIdAndroid = "XXXXXXX";
public string myGameIdIOS = "XXXXXXX";
	
public string adUnitIdAndroid = "Rewarded_Android";
public string adUnitIdIOS = "Rewarded_iOS";
public string myAdUnitId;
public string myAdStatus = "";
public bool adStarted;
public bool adCompleted;

private bool testMode = true;
```

**Important:** On lines 8 and 9, replace XXXXXXX with your Game IDs.

**8.**  In Start(), beginning on line 22, add:

```csharp
#if UNITY_IOS
	Advertisement.Initialize(myGameIdIOS, testMode, this);
	myAdUnitId = adUnitIdIOS;
#else
	Advertisement.Initialize(myGameIdAndroid, testMode, this);
	myAdUnitId = adUnitIdAndroid;
#endif
```

The code above sets some specific instructions to initialize the ad based on the hardware the app is running on.

## 4. Overview of the available Unity Ads Listeners

The IUnityAdsInitializationListener is an interface that has methods that handle Initialization results. These methods are:

- void OnInitializationComplete();
- void OnInitializationFailed(UnityAdsInitializationError error, string message);

The IUnityAdsLoadListener is an interface that has methods that handle Load results. These methods are:

- void OnUnityAdsAdLoaded(string adUnitId);
- void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message);

The IUnityAdsShowListener  is an interface that has methods that handle Show results.. These methods are:

- void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message);
- void OnUnityAdsShowStart(string adUnitId);
- void OnUnityAdsShowClick(string adUnitId);
- void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState);



Unity recommends implementing all methods in your code, even if you do not use them all.

## 5. Implement the listeners’ callback methods 

Now you’re ready to use those methods to complete your code:

**1.**  Starting on line 38 of your script, create the following methods:

```csharp
public void OnInitializationComplete()
    {
        Debug.Log("Unity Ads initialization complete.");
        Advertisement.Load(myAdUnitId,this);
    }

public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    }

public void OnUnityAdsAdLoaded(string adUnitId)
    {
        Debug.Log("Ad Loaded: " + adUnitId);
        if (!adStarted)
        {
            Advertisement.Show(myAdUnitId,this);
        }
    }
public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");

    }

public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
    }

public void OnUnityAdsShowStart(string adUnitId)
    {
        adStarted = true;
        Debug.Log("Ad Started: " + adUnitId);
    }

public void OnUnityAdsShowClick(string adUnitId)
    {
        Debug.Log("Ad Clicked: " + adUnitId);
    }

public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    {
        adCompleted = showCompletionState == UnityAdsShowCompletionState.COMPLETED;
        Debug.Log("Ad Completed: " + adUnitId);
    }
```


**2.**  Your RewardedAdDisplay script is complete. Save your changes, review the method summary below, and then return to the Unity Editor.

## Key methods of UnityAds listeners

The OnInitializationFailed, OnUnityAdsFailedToLoad, OnUnityAdsShowFailure methods will pass the error message to our myAdStatus variable.

The OnUnityAdsShowComplete  method will set the adCompleted variable to true so we can see the status in the Inspector when we run the Scene.

The OnUnityAdsShowStart  method will set the adStarted variable to true so we can stop trying to show the ad.

The OnUnityAdsAdLoaded  method will show the ad when it’s ready, as long as the ad has not already been displayed.

## Review the full RewardedAdDisplay script

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class RewardedAdDisplay : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
{
    public string myGameIdAndroid = "YOUR_GAME_ID_HERE";
    public string myGameIdIOS = "YOUR_GAME_ID_HERE";
    public string adUnitIdAndroid = "Rewarded_Android";
    public string adUnitIdIOS = "Rewarded_iOS";
    public string myAdUnitId;
    public string myAdStatus = "";
    public bool adStarted;
    public bool adCompleted;

    private bool testMode = true;

    // Start is called before the first frame update
    void Start()
    {
        #if UNITY_IOS
	        Advertisement.Initialize(myGameIdIOS, testMode, this);
	        myAdUnitId = adUnitIdIOS;
        #else
                Advertisement.Initialize(myGameIdAndroid, testMode, this);
                myAdUnitId = adUnitIdAndroid;
        #endif

    }

    // Update is called once per frame
    void Update()
    {

    }

    public void OnInitializationComplete()
    {
        Debug.Log("Unity Ads initialization complete.");
        Advertisement.Load(myAdUnitId,this);
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    }

    public void OnUnityAdsAdLoaded(string adUnitId)
    {
        Debug.Log("Ad Loaded: " + adUnitId);
        if (!adStarted)
        {
            Advertisement.Show(myAdUnitId,this);
        }
    }
    public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");

    }

    public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    {
        myAdStatus = message;
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
    }

    public void OnUnityAdsShowStart(string adUnitId)
    {
        adStarted = true;
        Debug.Log("Ad Started: " + adUnitId);
    }

    public void OnUnityAdsShowClick(string adUnitId)
    {
        Debug.Log("Ad Clicked: " + adUnitId);
    }

    public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    {
        adCompleted = showCompletionState == UnityAdsShowCompletionState.COMPLETED;
        Debug.Log("Ad Completed: " + adUnitId);
    }

}
```

## 6. Complete implementation and test the ad

Now you're ready to complete implementation and test the ad:

**1.**  In the Hierarchy, select the **RewardedAdDisplayObject** GameObject.

**2.**  In the Inspector window, select the lock icon (upper right corner).

**3.**  Direct your attention to the RewardedAdDisplay (Script) component.

![](https://connect-mediagw.unity.com/h1/20220706/learn/images/ab7dfcd4-1097-4c34-bc58-885311586deb_image1.png)

**4.**  Enter **Play** **Mode**. Note that the **Ad Started** property in the Inspector is enabled.

**5.**  In the Game view, select **Close** in the upper-right of the ad display. Note that the **Ad Completed** property in the Inspector is now also enabled.

**Note:** If there is an error, it will be displayed in the text box **My Ad Status** field.

**6.**  Exit Play Mode.

## 7. Next steps

You have now completed setting up Unity Rewarded Ads and can successfully display the rewarded ad. In your app, you will need to verify that AdCompleted is true and, if so, reward the player.
