Ad Unit

Before You Start

Before integrating ads unit in your app, you must:

  • In the OpenMediation UI, create an account, create an app, and create an ad placement. You can follow guides here.
  • Follow our steps to Unity Plugin Integration by integrating the Unity Plugin into your project.

The OpenMediation SDK is now included in your Unity app when you deploy it to either the Android or iOS platform. You're now ready to implement ad unit. OpenMediation Unity Plugin offers multiple ad types. You can choose the one that best fits your user experience needs.

 

Rewarded Video Ad

Rewarded video ads with strong interactive ability has become the mainstream form of mobile advertising industry. It is becoming increasingly common for mobile game developers to rely more on built-in ads than IAP to monetize.

The OpenMediation Rewarded Video ad unit offers an engaging ad experience that rewards your users with valuable virtual content in exchange for a completed view. This user-initiated ad unit is great for gaming apps, and enhances your apps experience. This section tells you how to init, load, and show Rewarded Video Ads.

Step 1. Implement Rewarded Video Events 

The OpenMediation Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

 OmEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvailabilityChangedEvent;
OmEvents.onRewardedVideoShowedEvent += RewardedVideoAdShowedEvent;
OmEvents.onRewardedVideoShowFailedEvent += RewardedVideoAdShowFailedEvent;
OmEvents.onRewardedVideoStartedEvent += RewardedVideoAdStartedEvent;
OmEvents.onRewardedVideoEndedEvent += RewardedVideoAdEndedEvent;
OmEvents.onRewardedVideoClickedEvent += RewardedVideoAdClickedEvent;
OmEvents.onRewardedVideoRewardedEvent += RewardedVideoAdRewardedEvent;
OmEvents.onRewardedVideoClosedEvent += RewardedVideoAdClosedEvent;

The Plugin will notify the Listener of all possible events listed below:

void RewardedVideoAvailabilityChangedEvent(bool available) {
    Debug.Log("unity-script: I got RewardedVideoAvailabilityChangedEvent, value = " +available);
}

void RewardedVideoAdShowedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdOpenedEvent: " + scene);
}

void RewardedVideoAdRewardedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdRewardedEvent: "+scene);
}

void RewardedVideoAdClosedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdClosedEvent: " +scene);
}

void RewardedVideoAdStartedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdStartedEvent: "+scene);
}

void RewardedVideoAdEndedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdEndedEvent: "+scene);
}

void RewardedVideoAdShowFailedEvent(string error) {
    Debug.Log("unity-script: I got RewardedVideoAdShowFailedEvent, error: " + error);
}

void RewardedVideoAdClickedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdClickedEvent, name = " + scene);
}

Note: Do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from callbacks need to be passed to the main thread before executing.

Step 2. Check Ad Availability

After the Rewarded Ad is successfully loaded, you will be notified when the ad is available to be shown through the RewardedVideoAvailabilityChangedEvent callback which will inform you the availability of ad inventory. 

public void RewardedVideoAvailabilityChangedEvent(bool available) {
Debug.Log("UnityApp RewardedVideo RewardedVideoAvailabilityChanged "+available);
}

Another way to check if the ad is available is by calling the isRewardedVideoReady function directly.

Om.Agent.isRewardedVideoReady();

Step 3. Show a RewardedVideo Ad

We strongly recommend checking the ad's availability by calling the isRewardedVideoReady method before you serve Rewarded Video .

if (Om.Agent.isRewardedVideoReady()) {
Om.Agent.showRewardedVideo("Your Video SceneName");
}

 

Interstitial Ad

The Interstitial is a full-screen ad unit, usually served at natural transition points during an app's lifecycle. Both static and video interstitials are supported.

Step 1. Implement Interstitial Events

The Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

 OmEvents.onInterstitialAvailabilityChangedEvent += InterstitialAdAvailabilityChangedEvent;
OmEvents.onInterstitialShowedEvent += InterstitialAdShowedEvent;
OmEvents.onInterstitialShowFailedEvent += InterstitialAdShowFailedEvent;
OmEvents.onInterstitialClickedEvent += InterstitialAdClickedEvent;
OmEvents.onInterstitialClosedEvent += InterstitialAdClosedEvent;

The Plugin will notify the Listener of all possible events listed below:

void InterstitialAdAvailabilityChangedEvent(bool available) {
    Debug.Log("unity-script: I got InterstitialAdReadyEvent: "+available);
}

void InterstitialAdShowFailedEvent(string error) {
    Debug.Log("unity-script: I got InterstitialAdShowFailedEvent, code: " +error);
}

void InterstitialAdClickedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClickedEvent: "+scene);
}

void InterstitialAdShowedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdOpenedEvent: "+scene);
}

void InterstitialAdClosedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClosedEvent: "+scene);
}

 Step 2. Check Ad Availability

After the Interstitial Ad is successfully loaded, you will be notified when the ad is available to be shown through the InterstitialAdAvailabilityChangedEvent callback which will inform you the availability of ad inventory. 

public void InterstitialAdAvailabilityChangedEvent(bool available) {
Debug.Log("UnityApp Interstitial InterstitialAdAvailabilityChanged " + available);
}

Another way to check if the ad is available is by calling the isInterstitialReady function directly.

Om.Agent.isInterstitialReady();

Step 3. Show a Interstitial Ad

We strongly recommend checking the ad's availability by calling the isInterstitialReady method before you serve Interstitial Ad .

if (Om.Agent.isInterstitialReady()) {
Om.Agent.showInterstitial("Your Video SceneName");
}

 

Banner Ad

Mobile banner ads are typically displayed at the top or bottom of the screen, and stick to the screen for the duration of the user’s session. Banner ads are a very popular ad unit for mobile apps because they are easy to implement and are a great tool for promoting advertiser awareness.

Step 1. Implement Banner Events

 OmEvents.onBannerLoadSuccessEvent += BannerLoadSuccessEvent;
OmEvents.onBannerLoadFailedEvent += BannerLoadFailedEvent;
OmEvents.onBannerClickedEvent += BannerClickedEvent;

The Plugin will notify the Listener of all possible events listed below:

void BannerLoadSuccessEvent(string placementId) {
Debug.Log("unity-script: I got BannerLoadSuccessEvent ");
}

void BannerLoadFailedEvent(string placementId, string error) {
Debug.Log("unity-script: I got BannerLoadFailedEvent: " + error);
}

void BannerClickedEvent(string placementId) {
Debug.Log("unity-script: I got BannerClickedEvent");
}

Step 2. Load Banner Ad

To load a Banner ad, call the following method:

Load the Banner view by calling this method (in this example it’s the BANNER banner size):

Om.Agent.loadBanner(placementId, AdSize.BANNER, BannerPostion.BOTTOM);

see table below for details about our supported standard banner sizes:

BannerSize Description Dimensions (WxH) (points in iOS, dp in Android)
BANNER Standard Banner 320 x 50
MEDIUM_RECTANGLE Large Banner 320 x 90
LEADERBOARD Medium Rectangular Banner 300 x 250
SMART
Smart Banner
(Adjusted for both mobile and tablet)
iOS:
If (iPhone) 320 x 50
If (iPad) 728 x 90
Android:
If (screen height ≤ 720) 320 x 50
If (screen height > 720) 728 x 90

See table below for details about our supported standard banner positions:

BannerPosition Description
TOP Banner will be positioned at the top center of the screen
BOTTOM Banner will be positioned at the bottom center of the screen

You will receive the BannerLoadSuccessEvent and the banner will show on your app.

Hide & Display Banner

In order to provide maximum flexibility in the ad experience, you now have the ability to hide and present banners on your app.

Unlike with the Android and iOS native implementations, when banner is loaded for the first time in Unity, it will show itself, and there won’t be a need to call displayBanner().

Once you’ve loaded and served a banner, you can choose to hide this banner and re-show it at a later point in your app.

To hide the banner, call this function:

Om.Agent.hideBanner(placementId);

 To then show this same banner again, call this function:

Om.Agent.displayBanner(placementId);

Step 3.Destroy Banner Ad

To destroy a banner, call the following method: 

Om.Agent.destroyBanner(placementId);

A destroyed banner can no longer be loaded. If you want to serve it again, you must initiate it again.

 

Promotion Ad

Step 1. Implement Promotion Events

The Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

OmEvents.onPromotionAdAvailabilityChangedEvent += PromotionAdAvailabilityChangedEvent;
OmEvents.onPromotionAdShowedEvent += PromotionAdShowedEvent;
OmEvents.onPromotionAdShowedEvent += PromotionAdShowFailedEvent;
OmEvents.onPromotionAdClickedEvent += PromotionAdClickedEvent;
OmEvents.onPromotionAdHiddenEvent += PromotionAdHiddenEvent;

The Plugin will notify the Listener of all possible events listed below:

void PromotionAdAvailabilityChangedEvent(bool available)
{
    OmUtils.printLogI("unity-script: I got PromotionAdAvailabilityChangedEvent: " + available);
}

void PromotionAdShowFailedEvent(string error)
{
    OmUtils.printLogI("unity-script: I got PromotionAdShowFailedEvent, code: " + error);
}

void PromotionAdClickedEvent(string scene)
{
    OmUtils.printLogI("unity-script: I got PromotionAdClickedEvent: " + scene);
}

void PromotionAdShowedEvent(string scene)
{
    OmUtils.printLogI("unity-script: I got PromotionAdShowedEvent: " + scene);
}

void PromotionAdHiddenEvent(string scene)
{
    OmUtils.printLogI("unity-script: I got PromotionAdHiddenEvent: " + scene);
}

Step 2. Check Ad Availability

After the Promotion Ad is successfully loaded, you will be notified when the ad is available to be shown through the PromotionAdAvailabilityChangedEvent callback which will inform you the availability of ad inventory. 

void PromotionAdAvailabilityChangedEvent(bool available) {
  Debug.Log("UnityApp Promotion PromotionAdAvailabilityChanged: " + available);
}

Another way to check if the ad is available is by calling the isPromotionAdReady function directly.

Om.Agent.isPromotionAdReady();

 

Step 3. Show a Promotion Ad

We recommend checking the ad's availability by calling the isPromotionAdReady method before you serve Promotion Ad .

if (Om.Agent.isPromotionAdReady()) {
Om.Agent.showPromotionAd(132, 0, 0, 0, 0);
}

Note: For Unity Android apps, if you want to successfully display cross-promotion ads, you need to enable Activity-level hardware acceleration.

 

Splash Ad

Step 1. Implement SplashAd Events

The Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

OmEvents.onSplashAdLoadSuccessEvent += SplashAdLoadSuccessEvent;
OmEvents.onSplashAdLoadFailedEvent += SplashAdLoadFailedEvent;
OmEvents.onSplashAdShowedEvent += SplashAdShowedEvent;
OmEvents.onSplashAdClickEvent += SplashAdClickEvent;
OmEvents.onSplashAdClosedEvent += SplashAdClosedEvent;
OmEvents.onSplashAdShowFailedEvent += SplashAdShowFailedEvent;

The Plugin will notify the Listener of all possible events listed below:

void SplashAdLoadSuccessEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdLoadSuccessEvent: " + placementId);
}

void SplashAdLoadFailedEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdLoadFailedEvent: " + placementId);
}

void SplashAdShowedEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdShowedEvent: " + placementId);
}

void SplashAdShowFailedEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdShowFailedEvent: " + placementId);
}

void SplashAdClickEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdClickEvent: " + placementId);
}

void SplashAdClosedEvent(string placementId)
{
    OmUtils.printLogI("unity-script: I got SplashAdClosedEvent: " + placementId);
}

 

Step 2. Load Splash Ad

To load a Splash ad, call the following method:

Om.Agent.loadSplashAd(placementId);

 

Step 3. Check Ad Availability

After the SplashAd is successfully loaded, you will be notified when the ad is available to be shown through the SplashAdLoadSuccessEvent callback which will inform you the availability of ad inventory. 

Another way to check if the ad is available is by calling the isSplashAdReady function directly.

Om.Agent.isSplashAdReady(placementId);

 

Step 4. Show a Splash Ad

We recommend checking the ad's availability by calling the isSplashAdReady method before you serve Splash Ad .

if (Om.Agent.isSplashAdReady(placementId)) {
Om.Agent.showSplashAd(placementId);
}

 

Tips:

Enable local logging: (For local debugging only. Remove it before going live.)

Om.Agent.debug(true);
Was this article helpful?
3 out of 4 found this helpful

Comments

0 comments

Article is closed for comments.