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초)
광고 로딩 시 각 네트워크 별로 타임아웃 시간을 주어 해당 시간 안에 광고를 받지 못할 경우, 다음 네트워크로 넘어갑니다.
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.");
};
}
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();
}
Excessive ad requests can lead to blocking, so please be cautious!
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)