🗂️
ONE AdMax Developer Guides
EN
EN
  • 00. about ONE AdMax
  • 01. How to Issue a Media Key
  • 02. How to Issue a Placement Key
  • 03. SDK for Java
    • 3-1. Rewarded Video Ads
    • 3-2. Interstitial Ads
    • 3-3. Banner Ads
    • 3-4. Interstitial Video Ads (Non Reward)
  • 04. Unity-Plugin Guide
    • 4-1. Rewarded Video Ads for Unity
    • 4-2. Interstitial Ads for Unity
    • 4-3. Banner Ads for Unity
    • 4-4. Interstitial Video Ads for Unity (Non Reward)
  • 05. Flutter-Plugin Guide
    • 5-1. 보상형 비디오 광고 for Flutter
    • 5-2. 전면 광고 for Flutter
    • 5-3. 배너 광고 구현하기
    • 5-4. 전면 비디오 광고 for Flutter (비보상형)
  • 📌Starting Mediation
  • ONE AdMax SDK Error Codes
  • SDK Version 안내 사항
    • SDK 1.2.0
    • SDK 1.0.2
Powered by GitBook
On this page
  • Before you begin
  • ONEAdMax SDK initialization
  • Interstitial Ads Sample Code
  • Creating an instance of Interstitial Ads.
  • Custom options for Interstitial Ads (optional).
  • Setting an event listener for Interstitial Ads (optional).
  • Creating Interstitial Ads
  • Interstitial Ads Load
  • Interstitial Ads 노출하기
  • Interstitial Ads Memory Destroy
  • Check whether the Interstitial Ads are loaded.
  1. 04. Unity-Plugin Guide

4-2. Interstitial Ads for Unity

It is an ad that covers the entire screen.

Previous4-1. Rewarded Video Ads for UnityNext4-3. Banner Ads for Unity

Last updated 4 months ago

Before you begin

ONEAdMax SDK initialization

Before loading ads, it is necessary to initialize ONEAdMax. The ONEAdMaxClient.Initialize() should only be performed once during the initial setup.

...
using ONEAdMax;
...
public class ONEAdMaxDemo : MonoBehaviour
{
    private static bool _isInitialized = false;
    
    void Start()
    {
        if (!_isInitialized)
        {
            // Initialize the ONEAdMax SDK.
            ONEAdMaxClient.Initialize(() =>
            {
                // This callback is called once the ONEAdMax SDK is initialized.
                _isInitialized = true
            });
        }
    }
}

Interstitial Ads Sample Code

You can create an instance of OAMInterstitial and extend its functionality by handling events.

Creating an instance of Interstitial Ads.

public class InterstitialAdController : MonoBehaviour
{   
    OAMInterstitial _interstitialAd;
    
    /// <summary>
    /// Creates the ad.
    /// </summary>
    public void CreateInterstitialAd()
    {
        Debug.Log("Creating Interstitial ad.");
        
        if (_interstitialAd != null)
        {
            Debug.LogWarning("Already have a Interstitial ad.");
            return;
        }

        _interstitialAd = new OAMInterstitial();
    }
}

Custom options for Interstitial Ads (optional).

/// <summary>
/// Customization of the ads screen.
/// </summary>
/// <seealso cref="CustomExtraKey"/>
/// <param name="ad"><see cref="OAMInterstitial"/></param>
private void SetCustomExtras(OAMInterstitial ad)
{
    var customExtras = new Dictionary<CustomExtraKey, object>
    {
        // Change interstitial ad background color and transparency (Defaults to "#FF000000")
        { CustomExtraKey.BACKGROUND_COLOR, "#FF000000" },

        // Set whether to show a close button in the top right corner of the interstitial ad. (Defaults to false)
        { CustomExtraKey.HIDE_CLOSE_BTN, false },

        // Change to False to provide a margin based on the ad image. (Defaults to true)
        { CustomExtraKey.CLOSE_BTN_MARGIN_FROM_EDGE, true },
        // Left margin of the interstitial ad close button. (Defaults to -28dp)
        { CustomExtraKey.CLOSE_BTN_LEFT_MARGIN, -28 },
        // Top margin of the interstitial ad close button. (Defaults to 20dp)
        { CustomExtraKey.CLOSE_BTN_TOP_MARGIN, 20 },
        // Right margin of the interstitial ad close button. (Defaults to 20dp)
        { CustomExtraKey.CLOSE_BTN_RIGHT_MARGIN, 20 },
        // Bottom margin of the interstitial ad close button. (Defaults to 0dp)
        { CustomExtraKey.CLOSE_BTN_BOTTOM_MARGIN, 0 },
        
        // Disable interstitial ad exit with a backkey. (Defaults to false)
        { CustomExtraKey.DISABLE_BACK_BTN, false },

        // Whether to show an exit message in interstitial ads. (Defaults to false)
        { CustomExtraKey.IS_ENDING_AD, false },
        // Change the exit ad message.
        { CustomExtraKey.ENDING_TEXT, "To exit, press the Back button one more time." },
        // Change the text size of the exit ad message.
        { CustomExtraKey.ENDING_TEXT_SIZE, 14 },
        // Change the text color of the exit ad message.
        { CustomExtraKey.ENDING_TEXT_COLOR, "#FFFFFFFF" },
        // Change the gravity of exit ad message.
        { CustomExtraKey.ENDING_TEXT_GRAVITY, OAMGravity.RIGHT },
    };

    ad.SetCustomExtras(customExtras);
}

Setting an event listener for Interstitial Ads (optional).

/// <summary>
/// Register to events the interstital ad may raise.
/// </summary>
private void RegisterEvents(OAMInterstitial ad)
{
    // Raised when an ad is loaded into the interstitial ad.
    ad.OnLoaded += () =>
    {
        Debug.Log("Interstitial ad loaded.");
    };

    // Raised when the interstitial ad fails to load.
    ad.OnLoadFailed += (OAMError error) =>
    {
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
    };

    // Raised when an ad opened full screen content.
    ad.OnOpened += () =>
    {
        Debug.Log("Interstitial ad has been opened.");
    };

    // Raised when the ad failed to open full screen content.
    ad.OnOpenFailed += (OAMError error) =>
    {
        Debug.LogError("Interstitial ad failed to open an ad with error : " + error);
    };

    // Raised when the ad closed full screen content.
    ad.OnClosed += (CloseEventType closeEventType) =>
    {
        Debug.LogError("Interstitial ad closed with type : " + closeEventType);
    };

    // Raised when a click is recorded for an ad.
    ad.OnClicked += () =>
    {
        Debug.Log("Interstitial ad was clicked.");
    };
}

Creating Interstitial Ads

Complete all the settings and create the OAMInterstitial.

// These ad units are configured to always serve test ads.   
private readonly string _placementId = "string your placement ID;"

_interstitialAd.Create(_placementId);

Interstitial Ads Load

Call the Load() API for interstitial ads to request an ad from the server.

/// <summary>
/// Loads the ad.
/// </summary>
public void Load()
{
    if (_interstitialAd == null)
    {
        Debug.LogWarning("The interstital ad is null.");
        return;
    }

    _interstitialAd.Load();
}

Excessive ad requests can be a reason for blocking, so please be cautious!

Interstitial Ads 노출하기

광고 로드가 완료되면 광고를 노출을 원하는 시점에 Show() API를 호출하여 화면에 노출 시킵니다.

/// <summary>
/// Shows the ad.
/// </summary>
public void Show()
{
    if (_interstitialAd != null && _interstitialAd.IsLoaded())
    {
        Debug.Log("Showing interstital ad.");
        _interstitialAd.Show();
    }
    else
    {
        Debug.LogError("The Interstitial ad hasn't loaded yet.");
    }
}

Interstitial Ads Memory Destroy

Destroy the memory within the instance of the interstitial ad.

/// <summary>
/// Destroys the ad.
/// </summary>
public void Destroy()
{
    if (_interstitialAd != null)
    {
        Debug.Log("Destroying interstitial ad.");
        _interstitialAd.Destroy();
        _interstitialAd = null;
    }
}

Check whether the Interstitial Ads are loaded.

Check whether the interstitial ad is loaded. (returns true | false)

_interstitialAd.IsLoaded();
04. Unity-Plugin Guide
ONE AdMax SDK Error Codes