facebook twitter hatena line email

「Unity/GoogleMobileAds/Interstitial」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(サンプル)
(admobのInterstitalとは)
行1: 行1:
 
==admobのInterstitalとは==
 
==admobのInterstitalとは==
 
全画面広告で、閉じるボタンが付いた広告。閉じるボタンは広告によって位置はまちまち。
 
全画面広告で、閉じるボタンが付いた広告。閉じるボタンは広告によって位置はまちまち。
 +
静止画や、動画が出る。
  
 
==admob公式==
 
==admob公式==

2022年4月16日 (土) 23:05時点における版

admobのInterstitalとは

全画面広告で、閉じるボタンが付いた広告。閉じるボタンは広告によって位置はまちまち。 静止画や、動画が出る。

admob公式

https://developers.google.com/admob/unity/interstitial?hl=ja

サンプル

using GoogleMobileAds.Api;
private InterstitialAd interstitial;
private void RequestInterstitial()
{
    #if UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/1033173712";
    #elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/4411468910";
    #else
        string adUnitId = "unexpected_platform";
    #endif
    interstitial = new InterstitialAd(adUnitId);
    // Called when an ad request has successfully loaded.
    interstitial.OnAdLoaded += HandleOnAdLoaded;
    // Called when an ad request failed to load.
    interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
    // Called when an ad is shown.
    interstitial.OnAdOpening += HandleOnAdOpened;
    // Called when the ad is closed.
    interstitial.OnAdClosed += HandleOnAdClosed;
    // Called when the ad click caused the user to leave the application.
    interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication;

    AdRequest request = new AdRequest.Builder()
                                         .AddTestDevice("F5E9973E1BED6D5E3F9xxxxxx")
                                         .Build();
    interstitial.LoadAd(request);
}

void ShowAd()
{
        if (interstitial.IsLoaded())
        {
            interstitial.Show();
        }
        else
        {
            MonoBehaviour.print("HandleShow Not loaded yet");
        }
}