4-4. Interstitial Video Ads for Unity (Non Reward)

It is the same format as video ads, but it is a type of ad that does not provide rewards.

Before you begin

04. Unity-Plugin Guide

ONEAdMax SDK initialize

Initialization of ONEAdMax is required before loading ads. ONEAdMaxClient.Initialize() should only be executed 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 Video Ads sample code

You can create an instance of OAMInterstitialVideo and handle events to extend its functionality.

Create an instance of the OAMInterstitialVideo ad.

public class InterstitialVideoAdController : MonoBehaviour
{
    OAMInterstitialVideo _interstitialVideoAd;
    
    /// <summary>
    /// Creates the ad.
    /// </summary>
    public void CreateInterstitialVideoAd()
    {
        Debug.Log("Creating Interstitial video ad.");
        
        if (_interstitialVideoAd != null)
        {
            Debug.LogWarning("Already have a Interstitial video ad.");
            return;
        }

        _interstitialVideoAd = new OAMInterstitialVideo();
    }
}

Set the network schedule timeout (optional)

๊ด‘๊ณ ์— ๋Œ€ํ•œ ๋„คํŠธ์›Œํฌ ์Šค์ผ€์ฅด ํƒ€์ž„์•„์›ƒ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. (๊ธฐ๋ณธ๊ฐ’: 5์ดˆ) ๊ด‘๊ณ  ๋กœ๋”ฉ ์‹œ ๊ฐ ๋„คํŠธ์›Œํฌ ๋ณ„๋กœ ํƒ€์ž„์•„์›ƒ ์‹œ๊ฐ„์„ ์ฃผ์–ด ํ•ด๋‹น ์‹œ๊ฐ„ ์•ˆ์— ๊ด‘๊ณ ๋ฅผ ๋ฐ›์ง€ ๋ชปํ•  ๊ฒฝ์šฐ, ๋‹ค์Œ ๋„คํŠธ์›Œํฌ๋กœ ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค.

_interstitialVideoAd.SetNetworkScheduleTimeout(5); // Default 5 seconds

Set the event listener for Interstitial Video Ads (optional)

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

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

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

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

    // Raised when the ad closed full screen content.
    ad.OnClosed += () =>
    {
        Debug.LogError("Interstitial video ad is closed.");
    };
}
ONE AdMax SDK Error Codes

Create an instance of the Interstitial Video Ad

Complete all the settings and create the OAMInterstitialVideo.

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

_interstitialVideoAd.Create(_placementId);

Load the Interstitial Video Ad.

์ „๋ฉด ๋น„๋””์˜ค ๊ด‘๊ณ  Load() API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์„œ๋ฒ„์— ๊ด‘๊ณ ๋ฅผ ์š”์ฒญํ•ฉ๋‹ˆ๋‹ค.

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

    _interstitialVideoAd.Load();
}

Display the Interstitial Video Ad.

๋กœ๋“œ๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ๊ด‘๊ณ ๋ฅผ ๋…ธ์ถœ์„ ์›ํ•˜๋Š” ์‹œ์ ์— Show() API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ํ™”๋ฉด์— ๋…ธ์ถœ ์‹œํ‚ต๋‹ˆ๋‹ค.

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

Destroy the memory for the Interstitial Video Ad.

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

Check whether the Interstitial Video Ad is loaded

Check whether the Interstitial Video Ad is loaded. (returns true | false)

_interstitialVideoAd.IsLoaded();

Last updated