C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5using GoogleMobileAds.Api; 6 7public class AdMob : MonoBehaviour { 8 9 void Start () { 10 string appId = "ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx"; 11 MobileAds.Initialize(appId); 12 RequestBanner(); 13 } 14 15 private void RequestBanner(){ 16 string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx"; 17 BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top); 18 AdRequest request = new AdRequest.Builder().Build(); 19 bannerView.LoadAd(request); 20 bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom); 21 } 22}
これを一番最初に読み込むシーンの空のオブジェクトにアタッチさせました。
appIdとadUnitIDはしっかり記入しました。
しかし、広告が表示されません。
UnityのConsoleウィンドウでもエラーがでません。
テストIDでも表示されません・・・
どこがダメなのでしょうか。コードの不良であるならば、訂正してほしいです。
お願いします。
それとも寝て待ってればAdMobの処理が勝手に終わる感じでしょうか?
Unity2018.1.2f1 Personal
こちらのサイトを参考にさせていただきました。
下記コンソールに表示されるメッセージ↓
Starting auto-resolution before scene build...
UnityEngine.Debug:Log(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:OnPostProcessScene()
UnityEditor.Build.BuildPipelineInterfaces:OnSceneProcess(Scene, BuildReport)
Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:MobileAdsInstance() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:87)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.MobileAds:GetMobileAdsClient() (at Assets/GoogleMobileAds/Api/MobileAds.cs:54)
GoogleMobileAds.Api.MobileAds:.cctor() (at Assets/GoogleMobileAds/Api/MobileAds.cs:24)
AdMob:Start() (at Assets/Scripts/AdMob.cs:15)
AdMob:Start() (at Assets/Scripts/AdMob.cs:13)
Dummy Initialize
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:Initialize(String) (at Assets/GoogleMobileAds/Common/DummyClient.cs:70)
GoogleMobileAds.Api.MobileAds:Initialize(String) (at Assets/GoogleMobileAds/Api/MobileAds.cs:28)
AdMob:Start() (at Assets/Scripts/AdMob.cs:13)
Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:BuildBannerClient() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:27)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:34)
AdMob:RequestBanner() (at Assets/Scripts/AdMob.cs:20)
AdMob:Start() (at Assets/Scripts/AdMob.cs:14)
Dummy CreateBannerView
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:CreateBannerView(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Common/DummyClient.cs:90)
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:35)
AdMob:RequestBanner() (at Assets/Scripts/AdMob.cs:20)
AdMob:Start() (at Assets/Scripts/AdMob.cs:14)
Dummy LoadAd
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Common/DummyClient.cs:100)
GoogleMobileAds.Api.BannerView:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Api/BannerView.cs:68)
AdMob:RequestBanner() (at Assets/Scripts/AdMob.cs:22)
AdMob:Start() (at Assets/Scripts/AdMob.cs:14)
Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:BuildBannerClient() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:27)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:34)
AdMob:RequestBanner() (at Assets/Scripts/AdMob.cs:23)
AdMob:Start() (at Assets/Scripts/AdMob.cs:14)
Dummy CreateBannerView
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:CreateBannerView(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Common/DummyClient.cs:90)
GoogleMobileAds.Api.BannerView:.ctor(String, AdSize, AdPosition) (at Assets/GoogleMobileAds/Api/BannerView.cs:35)
AdMob:RequestBanner() (at Assets/Scripts/AdMob.cs:23)
AdMob:Start() (at Assets/Scripts/AdMob.cs:14)