0
ユーザーがプレイする5つのゲームごとにインタースティシャル広告を表示しようとしています。私はここにコードをデバッグログに基づいて適切に呼び出されたと確信してインタースティシャル広告にadmobプラグインが表示されない
using UnityEngine;
using GoogleMobileAds.Api;
public class AdBetweenGames : MonoBehaviour {
InterstitialAd interstitial;
void Start()
{
if(PlayerPrefs.GetInt("games-played", -1) % 5 == 0)
{
this.ShowInterstitial();
}
}
private void RequestInterstitial()
{
string adUnitId = "UNITID";
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
}
public void ShowInterstitial()
{
RequestInterstitial();
Debug.Log("Interstatial ad called.");
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
}
:私がやったことは、次のスクリプトを使用して空のオブジェクトを作成しています。私はバナー広告をやってみましたが、1〜2秒後に問題なく表示されます。私はアンドロイドゲームを作っています。
また、広告を読み込むのに余分な時間が必要で、クリックしすぎるともう一度やり直すことができますか?しかし、解決策は何でしょうか?
最初に広告ユニットIDを投稿しないでください。安全ではありません。私はそれを削除alreade。二番目:あなたは待っていましたか?最初の広告が読み込まれるまでに時間がかかることがあります –
約2〜3秒待っていました。 –
Debug.Logを 'if(interstitial.IsLoaded())'の中に置き、それが本当であるかどうかを確認してください。 – Programmer