Unity 2017でAdmobのバナー広告を入れているのですが、いまいち理解できていないところがあり質問させていただきました。
StartScene、GameSceneなど二つのシーン間をまたぐ際は
①それぞれのシーンごとにAdmobDirectorを作って下記のスクリプト(ただしDontDestoryOnLoad(this)はつけない)を実行してバナーを毎回取得する。
②StartSceneだけ下記のスクリプトを実行してDontDestoryOnLoad(this)をつけてそのまま。
どちらの方が適切なのでしょうか?
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using GoogleMobileAds.Api; 5 6public class AdmobDirector : MonoBehaviour { 7 8 // Use this for initialization 9 void Start/*Awake*/ () { 10 DontDestroyOnLoad (this); 11 RequestBanner (); 12 } 13 14 private void RequestBanner() 15 { 16 #if UNITY_EDITOR 17 string adUnitId = "ca-app-pub-xxxxxxxxx"; 18 #elif UNITY_ANDROID 19 string adUnitId = "ca-app-pub-xxxxxxxxx"; 20 #elif UNITY_IPHONE 21 string adUnitId = "ca-app-pub-xxxxxxxxx"; 22 #else 23 string adUnitId = "unexpected_platform"; 24 #endif 25 26 // Create a 320x50 banner at the top of the screen. 27 BannerView bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom); 28 29 // Create an empty ad request. 30 //AdRequest request = new AdRequest.Builder().Build(); 31 //Create a test ad request. 32 AdRequest request = new AdRequest.Builder() 33 .AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator. 34 .AddTestDevice("xxxxxxxxxxxxxxxx") // My test device. 35 .Build(); 36 // Load the banner with the request. 37 bannerView.LoadAd(request); 38 } 39 40} 41
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/10 22:25
2017/10/14 15:17