Unityでアンドロイドアプリを作ってリリースしているのですが、
下段にadmobのバナー広告をいれておりテスト機にて不可解な現象が起きており同じような現象を経験されていれば教えていただきたく質問いたしました。
本番では起こっていないようなのですが、アップデート前に自分のandroid端末にてbuildして実行すると、広告が表示されず、さらにバナーすぐ上のボタンの半分くらいがマスクされてタップできない状態になります。(透明の大きめの広告が入っているような感じです)
UI部分は下記のスクリプトでバナーの高さを算出してその分上に配置するようにしています。
以上です。何か手がかりになりそうなことでも構わないので返信よろしくお願いいたします。
C#
1float height = 0; 2 float inches = Screen.height / Screen.dpi; 3 if (inches <= 2.5f) 4 height = 32; 5 else if (inches <= 4.5f) 6 height = 50; 7 else 8 height = 90; 9 bannerHeight = (float)(height) * Screen.dpi / 160.0f;
admobを表示するところは下記のようなソースコードです。
admobのチュートリアルとほとんど同じかと思います。
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-xxxxxxxxxx"; 18 #elif UNITY_ANDROID 19 string adUnitId = "ca-app-pub-xxxxxxxxxx"; 20 #elif UNITY_IPHONE 21 string adUnitId = "ca-app-pub-xxxxxxxxxx"; 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 //アップデートするときは上に切り替える 33 AdRequest request = new AdRequest.Builder() 34 .AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator. 35 .AddTestDevice("xxxxxxxxxxxxxxx") // My test device. 36 .Build(); 37 // Load the banner with the request. 38 bannerView.LoadAd(request); 39 } 40 41}
実行環境 Unity 2017.1.1f1
android端末 huawei P9
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/10 22:28