Add Ads to a Unity Game: LevelPlay Rewarded and Interstitial Ads

Illustration of a phone with a rewarded video and gift icon

For free mobile games, ads are usually the main income, and done well they don’t have to annoy players. A well-placed rewarded ad (“watch a video for an extra life”) is something many players actively choose. This guide shows how to add ads to a Unity game with LevelPlay, Unity’s ad mediation platform (from ironSource) that replaced the old standalone Unity Ads SDK as the recommended path. It covers setup, rewarded and interstitial ads in code, test mode, privacy consent, placement best practice, and fixes for “no fill” and other common problems.

Ad Formats: Rewarded, Interstitial, Banner

Format What it is Player experience Revenue
Rewarded Opt-in video, player gets a reward for watching Positive when the reward is worth it Highest per view
Interstitial Full-screen ad at a natural break Tolerated if infrequent, hated if not Medium
Banner Small strip at the top or bottom Low impact, but takes screen space Low

Most successful casual games lean on rewarded ads, add interstitials sparingly, and skip banners during gameplay.

Setting Up LevelPlay

  1. Create an account in the Unity Cloud dashboard and link your project (Edit > Project Settings > Services).
  2. In the dashboard, open LevelPlay, add your app for Android and/or iOS, and note each platform’s App Key.
  3. Create ad units (Rewarded, Interstitial, Banner) and copy their Ad Unit IDs.
  4. In the Unity Editor, install the Ads Mediation (LevelPlay) package from the Package Manager, or via the Services window.
  5. Open the LevelPlay Network Manager (Ads Mediation menu) and install the adapters for the networks you want to mediate. Start with Unity Ads, and add others like AdMob or AppLovin later for better fill and prices.
  6. Resolve Android dependencies when prompted (External Dependency Manager). If Gradle then fails, our Android Gradle build fix guide covers the usual causes.

SDK APIs change between versions, so check the version-specific docs in the package if a method name differs from the examples below. The structure (init, load, show, callbacks) stays the same.

Initializing the SDK

Initialize once at startup, ideally in a persistent object that loads before gameplay:

using Unity.Services.LevelPlay;
using UnityEngine;

public class AdsManager : MonoBehaviour
{
    public static AdsManager Instance { get; private set; }

    [SerializeField] string androidAppKey, iosAppKey;
    [SerializeField] string androidRewardedId, iosRewardedId;
    [SerializeField] string androidInterstitialId, iosInterstitialId;

    LevelPlayRewardedAd rewarded;
    LevelPlayInterstitialAd interstitial;

    void Awake()
    {
        if (Instance != null) { Destroy(gameObject); return; }
        Instance = this;
        DontDestroyOnLoad(gameObject);
    }

    void Start()
    {
#if UNITY_ANDROID
        string appKey = androidAppKey;
#else
        string appKey = iosAppKey;
#endif
        LevelPlay.OnInitSuccess += OnInitSuccess;
        LevelPlay.OnInitFailed += error => Debug.LogWarning($"LevelPlay init failed: {error}");
        LevelPlay.Init(appKey);
    }

    void OnInitSuccess(LevelPlayConfiguration config)
    {
        CreateRewarded();
        CreateInterstitial();
    }

    // ... rewarded and interstitial methods below
}

A persistent singleton is fine for an ads manager. Our singleton patterns guide explains how to avoid duplicates when scenes reload.

Rewarded Ads in Code

The pattern is: load early, show when ready, reward only in the reward callback, then load the next one.

System.Action pendingReward;

void CreateRewarded()
{
#if UNITY_ANDROID
    rewarded = new LevelPlayRewardedAd(androidRewardedId);
#else
    rewarded = new LevelPlayRewardedAd(iosRewardedId);
#endif
    rewarded.OnAdRewarded += (info, reward) => { pendingReward?.Invoke(); pendingReward = null; };
    rewarded.OnAdClosed += info => rewarded.LoadAd();                 // preload the next one
    rewarded.OnAdLoadFailed += error => Invoke(nameof(ReloadRewarded), 10f);
    rewarded.OnAdDisplayFailed += (info, error) => rewarded.LoadAd();
    rewarded.LoadAd();
}

void ReloadRewarded() => rewarded.LoadAd();

public bool RewardedReady => rewarded != null && rewarded.IsAdReady();

public void ShowRewarded(System.Action onRewarded)
{
    if (!RewardedReady) return;
    pendingReward = onRewarded;
    rewarded.ShowAd();
}

Usage from a “Continue?” screen:

continueButton.interactable = AdsManager.Instance.RewardedReady;
continueButton.onClick.AddListener(() =>
    AdsManager.Instance.ShowRewarded(() => player.Revive()));

Only enable the button when an ad is ready, so players never tap and get nothing. Grant the reward in OnAdRewarded, not on close: players who skip early shouldn’t get it, and callbacks can arrive in either order. If you store currency, save it right away (see our save system guide).

Interstitial Ads

[SerializeField] float minSecondsBetweenInterstitials = 180f;
float lastInterstitialTime = -999f;

void CreateInterstitial()
{
#if UNITY_ANDROID
    interstitial = new LevelPlayInterstitialAd(androidInterstitialId);
#else
    interstitial = new LevelPlayInterstitialAd(iosInterstitialId);
#endif
    interstitial.OnAdClosed += info => { Time.timeScale = 1f; AudioListener.pause = false; interstitial.LoadAd(); };
    interstitial.OnAdLoadFailed += error => Invoke(nameof(ReloadInterstitial), 15f);
    interstitial.LoadAd();
}

void ReloadInterstitial() => interstitial.LoadAd();

/// Call at natural breaks, e.g. after a level ends. Shows only if enough time has passed.
public void TryShowInterstitial()
{
    if (Time.realtimeSinceStartup - lastInterstitialTime < minSecondsBetweenInterstitials) return;
    if (interstitial == null || !interstitial.IsAdReady()) return;
    lastInterstitialTime = Time.realtimeSinceStartup;
    Time.timeScale = 0f;
    AudioListener.pause = true;
    interstitial.ShowAd();
}

Pausing time and audio prevents the game running behind the ad. A minimum interval protects players from ad spam, and many studios also skip interstitials for the first few sessions.

💰 Thinking about monetization early?

Business-of-games books cover ads, IAP and retention far better than any SDK doc. A few are on our reading list.

See the game dev reading list →

Testing Ads Safely

  • Never click your own live ads. Ad networks detect it and can ban your account.
  • Enable test mode for your app in the LevelPlay dashboard, and register your devices as test devices (by advertising ID) so they always receive test ads.
  • Use the LevelPlay Integration Test Suite (LevelPlay.LaunchTestSuite() after setting the test suite metadata) to verify each network adapter on a real device.
  • In the Editor, ads are simulated or unavailable. Real behaviour needs a device build (see the iOS build guide for iPhone testing).

Privacy, Consent and App Store Rules

Ads use personal data, so legal requirements apply:

  • GDPR / UK GDPR (EU and UK users): you need consent before personalized ads. Use a consent management platform (Google’s UMP or another certified CMP) and pass the result to LevelPlay with LevelPlay.SetConsent(bool) before init.
  • US state privacy laws: honour “do not sell” choices with the do_not_sell metadata.
  • Children (COPPA, Google Play Families): if your game targets kids, flag it (is_child_directed) and use only family-certified networks. Personalized ads aren’t allowed.
  • iOS App Tracking Transparency: show the ATT prompt (and add an NSUserTrackingUsageDescription) before requesting the IDFA, and include the networks’ SKAdNetwork IDs in Info.plist.
  • Declare ads and data collection in Google Play’s Data safety form and Apple’s privacy labels, and link a privacy policy.

This isn’t legal advice. Requirements change, so check current rules for your markets.

Ad Placement That Doesn’t Drive Players Away

  • Rewarded placements that feel generous: continue after death, double level rewards, a free daily chest, hints in puzzle games.
  • Interstitials only at natural breaks: after a level, never mid-action or right after the player taps a button (accidental clicks also hurt your account standing).
  • Offer a “Remove Ads” purchase. A one-time IAP is often a meaningful extra income stream.
  • Measure retention alongside ad revenue. If day-1 retention drops after adding interstitials, the ads are costing more than they earn. Our publishing guide covers launch checklists that include analytics.

Troubleshooting

Ads never load (“No Fill”)

New apps often have low fill, which improves after store publishing and real traffic. Confirm the app key and ad unit IDs match the platform, test mode or test devices are set up, adapters are installed, and the app is live or linked in each network’s dashboard.

Init fails or callbacks never fire

Subscribe to events before calling Init or LoadAd, and check the device log (Logcat or Xcode) for the SDK’s own error messages. Make sure the app key is for the right platform.

Reward granted twice or not at all

Reward logic is in OnAdClosed, or the callback isn’t cleared after use. Grant only in OnAdRewarded and null out the pending action.

Android build fails after adding the SDK

Duplicate libraries or missing dependency resolution. Run Assets > External Dependency Manager > Android Resolver > Force Resolve, and enable custom Gradle templates if the docs require them.

Game audio keeps playing during ads

Pause the AudioListener and timeScale when showing, and restore them on close and on display failure.

FAQ

Is Unity Ads the same as LevelPlay?

Unity Ads is an ad network. LevelPlay is Unity’s mediation platform that can serve Unity Ads plus other networks, and it’s the recommended integration path for new projects.

How much money do mobile game ads make?

It varies hugely by country, genre and engagement. Rewarded video earns the most per view. Measure your own eCPM rather than relying on averages.

Can I test ads in the Unity Editor?

Only partially. Real ad loading and display need a device build with test mode or test devices enabled.

Should I use banners?

They earn little and take screen space. Many games use them only on menus, or not at all.

Do I need consent to show ads?

For personalized ads to EU and UK users, yes, under GDPR. Use a certified consent platform and pass the result to the SDK.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *