困っていること
unityで簡単な2Dゲームを作っているのですが、admobでunity上ではテスト用のバナー広告とインタースティシャル広告が出るのですが、ビルドしてAndroid端末で実機テストしてみると広告が出ません。また、エラーも出ておらず困っています。使っているunityのバージョンは2020.3.17です。
使っているスクリプト
下のAdsManager.csは広告を出しているスクリプトです。変数にはテスト用IDを入れています。
using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api; using System; public class AdsManager : MonoBehaviour { public string android_Banner1; public string android_Interstitial; private InterstitialAd interstitial; private AdRequest request; bool is_close_interstitial = false; private int reShowCount; void Awake() { reShowCount = 0; RequestInterstitial(); RequestBanner(); } public void RequestBanner() { #if UNITY_ANDROID string adUnitId1 = android_Banner1; #elif UNITY_IPHONE string adUnitId1 = ios_Banner1; string adUnitId2 = ios_Banner2; #else string adUnitId = "unexpected_platform"; #endif BannerView bannerView1 = new BannerView(adUnitId1, AdSize.Banner, AdPosition.Top); request = new AdRequest.Builder() .Build(); bannerView1.LoadAd(request); } public void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = android_Interstitial; #elif UNITY_IPHONE string adUnitId = ios_Interstitial; #else string adUnitId = "unexpected_platform"; #endif if (is_close_interstitial == true) { interstitial.Destroy(); } interstitial = new InterstitialAd(adUnitId); request = new AdRequest.Builder() .Build(); interstitial.LoadAd(request); interstitial.OnAdClosed += HandleAdClosed; interstitial.OnAdFailedToLoad += HandleAdReLoad; is_close_interstitial = false; } void HandleAdClosed(object sender, System.EventArgs e) { is_close_interstitial = true; RequestInterstitial(); } void HandleAdReLoad(object sender, System.EventArgs e) { is_close_interstitial = true; StartCoroutine(_waitConnect()); } IEnumerator _waitConnect() { while (true) { yield return new WaitForSeconds(30.0f); if (Application.internetReachability != NetworkReachability.NotReachable) { RequestInterstitial(); break; } } } public void InterstitialShow() { if (interstitial.IsLoaded()) { interstitial.Show(); reShowCount = 0; } else { if (reShowCount < 10) { Invoke("InterstitialShow", 0.1f); reShowCount++; } else { reShowCount = 0; } } } }
そして、針に当たったら、InterstitialShow()関数を、有効にしています。
試したこと
Force Resolveを試してみたり、プロジェクトをバージョンアップさせてみたりしましたが、意味がありませんでした。
あなたの回答
tips
プレビュー