Skip to content

About

Reusable Unity LevelPlay (Ads Mediation) helper: init, consent, interstitial/rewarded/banner with retries and ILRD events. Git-URL installable UPM package with auto-update notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Level Play Helper

Unity LevelPlay SDK Version License: MIT Install

A drop-in, production-ready manager for Unity LevelPlay (Ads Mediation). Add one component, fill in your keys, and get SDK initialization, GDPR/CCPA/COPPA consent, interstitial/rewarded/banner lifecycle with exponential-backoff retries, impression-level revenue events (ILRD), deep Unity Ads & ironSource demand diagnostics, an in-editor LevelPlay Manager window built with modern UI Toolkit, and a unified custom inspector — all without writing mediation boilerplate in your game code.


Table of Contents


Why this package

Integrating LevelPlay directly usually requires writing ~500 lines of lifecycle, error retry, threading, and consent plumbing into every project. Developers frequently encounter tricky edge cases:

  • What happens when a rewarded ad isn't ready when the player taps the button?
  • Why is Unity Ads missing or failing to fill even though the adapter is installed?
  • Did you turn off the Test Suite before shipping to Google Play or the App Store?
  • Did you configure GDPR and CCPA before initializing the SDK?

LevelPlayHelper centralizes all of this once, tested, and versioned — so your game only handles game-specific ad cadence and UI rewards.


Installation (Unity Package Manager - Git URL)

  1. Open Window > Package Manager
  2. Click + > Add package from git URL...
  3. Paste:
https://github.com/wagenheimer/UnityLevelPlayHelper.git

To pin a specific release:

https://github.com/wagenheimer/UnityLevelPlayHelper.git#vX.Y.Z

The helper requires com.wagenheimer.tracking, which owns App Tracking Transparency on iOS. UPM cannot list a git URL as a dependency, so a small editor bootstrap adds https://github.com/wagenheimer/UnityTracking.git#v0.8.0 to the manifest the first time the helper loads without it (or with a version older than 0.5.0). Until it arrives the helper's own assemblies report missing Wagenheimer.Tracking types; they compile as soon as Unity resolves the package. To add it yourself:

https://github.com/wagenheimer/UnityTracking.git#v0.8.0

Requirements

Requirement Version
Unity 2022.3 LTS or newer (tested up to Unity 6)
Ads Mediation package (com.unity.services.levelplay) 9.5.1 (stable UPM release)
Native dependency resolver Mobile Dependency Resolver (MDR) or EDM4U
Tracking package (com.wagenheimer.tracking) 0.5.0 or newer (auto-installed, v0.8.0)

Quick Start

  1. Add the LevelPlayHelper component to a persistent GameObject in your first scene (or use a prefab under Resources).
  2. Open Tools > Wagenheimer > Level Play Helper > LevelPlay Manager... (or select the component Inspector).
  3. Start on the Overview tab and follow Next step. Fill in the App Key and Ad Unit IDs in the Ad Units tab (or connect your account in the LevelPlay Account tab and press Use all from the account).
  4. Press Play — mock ads load automatically in the Unity Editor for instant testing!
// 1. Show an interstitial ad
LevelPlayHelper.Instance.ShowInterstitial();

// 2. Show a rewarded ad (reward callback only fires when earned)
LevelPlayHelper.Instance.ShowRewardedAd(() =>
{
    player.AddCoins(50);
});

// 3. Show a banner ad
LevelPlayHelper.Instance.ShowBanner();

LevelPlay Manager (UI Toolkit Editor Tool)

Open Tools > Wagenheimer > Level Play Helper > LevelPlay Manager.... The same dashboard is the LevelPlayHelper Inspector. It has five tabs, ordered by what you do:

┌────────────────────────────────────────────────────────────────────────────┐
│  LevelPlay Manager  v2.x            [LevelPlay website] [Docs] [Refresh]   │
├────────────────────────────────────────────────────────────────────────────┤
│ [ Overview (2) ] [ Ad Units ] [ Ads & Privacy ] [ Testing ] [ LevelPlay Account ] │
└────────────────────────────────────────────────────────────────────────────┘

Overview: what is done, what is missing, what to click

  • Status at the top: Ready, Almost ready: N items to review or N problems block ads or the build, with the next step and its button.
  • To do: every failure, then every warning. Each item has one obvious button: its one-click fix, the Manager tab where you fix it, or Copy AI prompt (a ready-to-paste task built from the item's evidence).
  • Fix all automatic, Copy to-do list as AI prompt and Copy full report (Markdown).
  • All checks by area (collapsed): SDK & packages, Account & ad units, Privacy & consent, Android & iOS build settings, Game code, Release flags, Testing in the Editor, Before you ship (manual).
  • The tab title shows how many items are open, e.g. Overview (2).

Ad Units: the game next to your LevelPlay account

  • One card per platform with the App Key and the Rewarded / Interstitial / Banner IDs stored on the helper prefab (editable, with Undo) next to the values of the matching app in your LevelPlay account.
  • Different values are highlighted; Use copies one value, Use all from the account copies them all.
  • The account app is picked from the App Key already on the prefab, then from the Player Settings bundle id, and can be changed in the Account app dropdown (useful when a build profile switches the bundle id, e.g. Free and paid apps in one project).
  • Needs the LevelPlay account connected (LevelPlay Account tab). Loading only reads the account.

Ads & Privacy

  • Ad pacing (AdsConfiguration): initial interval, minimum interval and how fast it shrinks.
  • Privacy flags (ConsentConfiguration): GDPR, CCPA/CPRA opt-out, COPPA.
  • App Tracking Transparency (iOS): request toggle and NSUserTrackingUsageDescription.

Testing

  • LevelPlay Test Suite on device, in-game debug overlay (ADS DBG / F8), Editor mock ads (with Block builds while enabled) and a Development Build toggle.

LevelPlay Account

  1. Connect with the Secret Key and Refresh Token from My Account > API (saved in EditorPrefs only).
  2. Apps and 3. Ad units in the account, with "Use this key/ID" buttons.
  3. Ad networks: ironSource + Unity Ads status per ad unit, the Unity Ads setup steps and Set up Unity Ads... (see Step 3).
  4. Game vs account check (the same result the Overview shows).

Reading never changes the account. Creating an app, ad units or network instances always asks first.


Unity Ads & LevelPlay Step-by-Step Integration Guide

LevelPlay requires concurrent demand from both ironSource and Unity Ads to maximize auction competition and fill rates.

Because Unity migrated to the new Unity Cloud Dashboard, follow these 4 steps in the LevelPlay Account tab:

flowchart LR
    A["1. Client Adapter<br/>(ISUnityAdsAdapter)"] --> B["2. SDK Networks<br/>(Link Org & Key)"]
    B --> C["3. App Instances<br/>(Game ID & Formats)"]
    C --> D["4. Live Verification<br/>(Fetch & Verify)"]
Loading

Step 1: Install the Unity Ads Adapter (Client-Side)

  • Open Ads Mediation > Network Manager in Unity.
  • Verify Unity Ads adapter is installed (version 5.14.0+).
  • The helper will detect ISUnityAdsAdapterDependencies.xml automatically.

Step 2: Link Unity Ads in the LevelPlay Dashboard (Account-Level)

  1. In the helper, click Open SDK Networks (navigates to https://platform.ironsrc.com/partners/next/networks).
  2. Locate Unity Ads and enter:
    • API Key: Your Unity Ads API Key.
    • Organization Core ID: Your Unity Organization ID (e.g. 22730).
  3. ⚠️ IMPORTANT: Turn OFF the toggle for Bidder auto-setup. (The new Unity Cloud dashboard uses manual instance mapping; keeping auto-setup on will produce an error).
  4. Click Save.

Step 3: Game ID, placements and instances (per app)

  1. Find the right Game ID. Unity Cloud > Apps > your app > Monetization tab > Game ID: the same number shown beside the placements in Monetization > Placements (one per platform, digits only, e.g. 3658283). Do not use:

    • the "MMP settings" Game ID under User Acquisition (8002xxxxx);
    • the Game ID shown in the "Complete app integration" dialog;
    • the Unity Cloud project ID (a UUID such as 88b78abb-...).

    A wrong Game ID never errors: Unity Ads simply never fills and only ironSource serves. The checker reports a UUID or an 8002xxxxx value as an error.

  2. Put it on the prefab: Ad Units tab > platform > Unity Ads Game ID (androidUnityAdsGameId / iosUnityAdsGameId).

  3. Create the placements in Unity Cloud > Monetization > Placements > Create placement: BP_Rewarded_Android, BP_Interstitial_Android, BP_Rewarded_iOS, BP_Interstitial_iOS. The LevelPlay API cannot create placements.

  4. Press Set up Unity Ads... (LevelPlay Account tab, or the action on the Overview's Dashboard cross-check). It reads the account, lists every change, and only writes after you confirm:

    • fixes a wrong Game ID on all Unity Ads instances of the app in one request (LevelPlay requires the same app config on every instance of a network, otherwise ERR-1401);
    • turns Unity Ads instances live and sets the BP_* placement when it differs;
    • creates the missing bidders UnityAds_Rewarded / UnityAds_Interstitial;
    • adds ironSource + Unity Ads to each ad unit's mediation group (the group's instance list is replaced, so the ids already there are always resent).

Step 4: Verification

The Overview (Dashboard cross-check) and the LevelPlay Account tab (Game vs account check) fail when, for any rewarded or interstitial ad unit on the prefab:

  • there is no unityAds instance, or it is not live;
  • the Unity Ads Game ID in the dashboard is not a plain number (a UUID, an 8002xxxxx MMP id), differs between instances, or differs from the Game ID on the prefab;
  • the instance's placement is not BP_<Rewarded|Interstitial>_<Android|iOS>;
  • the instance is not in the ad unit's mediation group, or the group has no instances at all.

From the command line

The same check and setup can run from a script, e.g. with the Unity CLI against an open Editor:

unity command script eval --code "return await Wagenheimer.LevelPlayHelper.Editor.LevelPlayUnityAdsCommands.CheckAsync();"
unity command script eval --code "return await Wagenheimer.LevelPlayHelper.Editor.LevelPlayUnityAdsCommands.PlanAsync();"
unity command script eval --code "return await Wagenheimer.LevelPlayHelper.Editor.LevelPlayUnityAdsCommands.SetupAsync();"

CheckAsync and PlanAsync only read the account (PlanAsync is the dry run of the setup). SetupAsync shows the confirmation dialog in the Editor before writing. The API credentials stay in EditorPrefs and are never printed.


Custom Inspector

Selecting any LevelPlayHelper (or your custom subclass) in the Unity hierarchy or project assets displays the full UI Toolkit editor:

  • Quick Header: Displays current package version, SDK status, and direct buttons for Manager Window, Dashboard, and Documentation.
  • Embedded Tabs: The same Overview, Ad Units, Ads & Privacy, Testing and LevelPlay Account tabs, inside the Inspector (it opens on Ad Units).
  • Inspector Mode Adaptations: Clean layout designed specifically for standard Inspector widths with full data-binding support.

Configuration Reference

Field Type Default Description
androidAppKey / iosAppKey string "" App Key from LevelPlay dashboard per platform.
androidInterstitialAdUnitId / iosInterstitialAdUnitId string "" Interstitial Ad Unit ID (empty = disabled).
androidRewardedAdUnitId / iosRewardedAdUnitId string "" Rewarded Ad Unit ID (empty = disabled).
androidBannerAdUnitId / iosBannerAdUnitId string "" Banner Ad Unit ID (empty = disabled).
androidUnityAdsGameId / iosUnityAdsGameId string "" Editor only. Unity Ads Monetization Game ID (Unity Cloud > Apps > app > Monetization tab). Used by the checker and Set up Unity Ads; not the MMP Game ID (8002xxxxx) nor the project UUID.
bannerPosition BannerPositionPreset BottomCenter One of 9 standard LevelPlay banner positions.
adsConfig AdsConfiguration — Cadence intervals and reduction thresholds.
consentConfig ConsentConfiguration - GDPR, CCPA/CPRA, and COPPA compliance flags.
enableTestSuite bool false Launches on-device LevelPlay Test Suite after init.
enableDebugOverlay bool true Enables the runtime ADS DBG / F8 diagnostic overlay.

API Reference

Lifecycle

  • LevelPlayHelper.Instance: Static singleton access.
  • LevelPlayHelper.Instance.Initialize(): Applies privacy settings and initializes the SDK.
  • LevelPlayHelper.Instance.IsSdkInitialized: True once initialization finishes.
  • LevelPlayHelper.Instance.TrackingState: ATT status read before init (TrackingAuthorizationState, NotSupported outside iOS). Read-only: com.wagenheimer.tracking asks.
  • LevelPlayHelper.Instance.SetUserConsent(bool): Updates and persists GDPR consent in PlayerPrefs.

Ad Display

  • ShowInterstitial(): Displays interstitial ad if ready; initiates reload on failure.
  • IsInterstitialReady(): Returns readiness state for interstitials.
  • ShowRewardedAd(Action onReward): Shows rewarded ad; invokes onReward callback only when earned.
  • IsRewardedAdReady(): Returns readiness state for rewarded ads.
  • TryShowAd(Action onReward): Fallback method prioritizing rewarded ads over interstitials.
  • ShowBanner() / HideBanner() / DestroyBanner(): Controls banner display and memory lifecycle.

Events

All events are static, allowing subscription from any system without holding instance references:

LevelPlayHelper.OnSdkInitialized      += config => { /* SDK ready */ };
LevelPlayHelper.OnInterstitialClosed  += () => { /* Resume gameplay */ };
LevelPlayHelper.OnRewardedAdGranted   += () => { /* Reward granted */ };
LevelPlayHelper.OnAdDisplayed         += format => { /* Pause game audio */ };
LevelPlayHelper.OnAdClosed            += format => { /* Resume game audio */ };
LevelPlayHelper.OnAdRevenuePaid       += (adUnitId, revenue) => { /* ILRD analytics */ };
LevelPlayHelper.OnImpressionDataReady += data => { /* Raw SDK payload (background thread) */ };
LevelPlayHelper.OnTrackingAuthorizationCompleted += state => { /* ATT status read before init (iOS) */ };

OnAdClosed fires for both "Interstitial" and "Rewarded" (including a skipped rewarded), so it is the right hook to restore anything paused when the ad opened:

LevelPlayHelper.OnAdDisplayed += format =>
{
    if (format != "Banner") AdAudioPause.Pause(); // e.g. AudioListener.pause = true
};
LevelPlayHelper.OnAdClosed += format =>
{
    if (format != "Banner") AdAudioPause.Resume();
};

App Tracking Transparency (iOS)

ATT belongs to com.wagenheimer.tracking (required, installed automatically). The helper has no ATT settings of its own since 3.0.0:

  • the tracking package shows the native alert and writes NSUserTrackingUsageDescription only into the build profiles that declare tracking - configure it in its settings asset and Tools > Wagenheimer > Tracking > Tracking Checker;
  • LevelPlay.Init() always waits for TrackingConsent.IsResolved (when TrackingConsent.IsRequired), so the SDK reads the advertising identifier only after the player answered. No project code is needed;
  • TrackingState and OnTrackingAuthorizationCompleted still report the status the helper read just before init.

The setup checker fails when the tracking package is missing or older than 0.5.0, with a one-click install/update.

Extra initialization gates

LevelPlayHelper.InitializationGate is chained, not replaced: the tracking wait, ConsentGate and your own predicate must all be true before LevelPlay.Init().

LevelPlayHelper.InitializationGate = () => myConsentOwner.IsResolved;

Initialize() (including the automatic call from Start) waits for the gates (60s by default, InitializationGateTimeoutSeconds) before calling LevelPlay.Init(). If the prefab is created before the answer, the SDK still does not read the IDFA too early.

Consent gate (GDPR / CCPA / COPPA)

ConsentGate is the reusable consent owner for projects that must ask before ads initialize. Add it next to LevelPlayHelper on the same prefab and assign a ConsentLocalization asset (create one from Assets > Create > Tools > Wagenheimer > Level Play > Consent Localization).

LevelPlayHelper.prefab
  LevelPlayHelper       (ads)
  ConsentGate           (consent + standard dialog)

What it does:

  • stores the answer in PlayerPrefs under UserConsent (the key the helper already reads);
  • calls LevelPlayHelper.Instance.SetUserConsent(...) immediately;
  • while the answer is missing, keeps LevelPlayHelper.InitializationGate closed, so LevelPlay.Init() waits (60s by default) instead of running without consent;
  • shows the package's standard dialog on first launch, or you can call Grant() / Deny() from your own UI.

The standard dialog is built at runtime with UI Toolkit - no prefab to import and no localization package dependency. It reads every string from the localization asset and falls back to English when a language is incomplete. Assign a theme or a legacy Font on the gate when the default font does not cover your script (for example Korean).

ConsentLocalization has one entry per language and a requiredLanguageCodes list. The LevelPlay Manager's Overview tab finds the gate in your prefabs/scenes and reports every required language that is missing or has an empty title, body, accept or decline string.

One-click setup

GDPR consent is on by default, so Overview > Privacy & consent flags a helper that has no gate and offers Add consent gate (a helper created with Create prefab gets one automatically). That button:

  • adds ConsentGate next to LevelPlayHelper (inside the prefab, or on the scene object);
  • creates Assets/LevelPlay/Resources/ConsentLocalization.asset for the languages the game already ships (read from I2 Localization sources or Unity Localization locales; English when neither is used), filled from built-in translations: en, pt-BR, es, fr, de, it, nl, pl, tr, ru, ko, ja, zh-Hans, zh-Hant;
  • copies the privacy-policy and terms links the game's own scripts already open;
  • assigns a project font to Korean, Japanese or Chinese entries when one is found by file name (for example NotoSansKR).

Whatever it cannot settle stays on the checklist with its own fix button: missing links, languages without a built-in translation (Fill translations never overwrites text you wrote), fonts, and Players can change their consent, which passes when game code reopens the dialog (ConsentGate.Instance.ShowDialog() from a privacy/settings button). Whether GDPR applies to your game is a legal question: if it does not, turn enableGDPRConsent off instead of adding the gate. Review the built-in texts with your own legal and localization team before shipping.

From an editor script or an AI agent, the same setup is Wagenheimer.LevelPlayHelper.Editor.ConsentSetup.AddGate(helper).


Fallback Behavior (Rewarded Ads)

To protect user experience and retain players even during ad network outages, ShowRewardedAd executes a graceful fallback strategy:

  1. Rewarded ad is ready → Displays ad and grants reward upon completion.
  2. Rewarded not ready, Interstitial is ready → Shows interstitial and grants reward immediately.
  3. No ads available → Grants reward directly without showing an ad.

In all cases, an ad reload is queued immediately with exponential backoff.


Runtime Debug Overlay (F8)

In the Unity Editor and Development Builds, tap the ADS DBG button or press F8 to open the runtime diagnostic HUD:

  • WHY NOT LOADING Banner: Diagnoses the exact root cause of delivery failures (missing keys, consent not granted, paused units, mock state).
  • State Machine Inspection: Real-time status (Idle, Loading, Ready, Showing, Failed).
  • Live Event Log: Color-coded, thread-safe event log with instant Copy Report to clipboard.
  • Interactive Triggers: Manually trigger ad loads, shows, banner toggles, and consent testing.
  • Consent Gate Card: resolved/consent/stored state, InitializationGate status, localization asset and resolved language, missing translations, Grant / Deny / Reset / Show dialog, one-click preview of every language and a copyable consent report.

Production Release Checklist

Before building for release:

  • Open LevelPlay Manager > Overview and make sure it says Ready (no items under To do).
  • Verify both ironSource and Unity Ads are marked LIVE in the LevelPlay Account tab, and the Dashboard cross-check has no Unity Ads error (Game ID, BP_* placements, mediation groups).
  • Ensure Enable Test Suite is disabled.
  • Confirm real App Keys and Ad Unit IDs are entered (no placeholders).
  • Verify native dependencies resolved (Assets > External Dependency Manager > Android/iOS Resolver).
  • On Android, verify AD_ID permission is declared for target API 33+.

Architecture

Your Game Logic
  └── LevelPlayHelper (Singleton MonoBehaviour)
        ├── LevelPlayPrivacySettings (GDPR / CCPA / COPPA)
        ├── LevelPlayAdFormat (Rewarded / Interstitial / Banner)
        └── Unity.Services.LevelPlay (Ads Mediation SDK v9.5.1)
              ├── ironSource Network Demand
              └── Unity Ads Network Demand (Bidding & Waterfall)

License

Distributed under the MIT License.


Wagenheimer Unity ecosystem

Package Hub · Unity Utils · Build Pipeline · Cloud Save · Rate Control · IAP Helper · LevelPlay Helper · Native Social · Rewired Helper · Timeline Typewriter · Tk2d Porter · Tracking · I2 Localization

Explore every project at wagenheimer.com/opensource.

About

Reusable Unity LevelPlay (Ads Mediation) helper: init, consent, interstitial/rewarded/banner with retries and ILRD events. Git-URL installable UPM package with auto-update notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages