Unity Google AdMob Banner
Hello!
I've been following Google's Unity AdMob guide at this website: https://developers.google.com/admob/unity/start
I've been trying to implement a banner ad type to an Android game. I imported the provided package and also used the Play Service Android Resolver in order to include the Mobile Android SDK.
The problem is that all the Ads work properly except the banner. In the position where the banner is supposed to be the UI elements like buttons do not work, they are blocked by something on top of them, so it seems like the banner is there, however not visible. I have tested this on 2 different Android devices and the result was the same.
Here is the code that I am using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds;
public class adMobBannerScript : MonoBehaviour {
private BannerView bannerView;
public void Start () {
#if UNITY_ANDROID
string appId = "Hidden";
#elif UNITY_IPHONE
string appId = "Hidden";
#else
string appId = "unexpected_platform";
#endif
MobileAds.Initialize (appId);
this.RequestBanner ();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/6300978111";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
if (bannerView != null)
{
bannerView.Destroy();
}
bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder ().Build ();
// Load the banner with the request.
bannerView.LoadAd (request);
}
public void destroyBanner()
{
bannerView.Destroy ();
}
}
And here is the unity log when I run the code: Thank you very much for your time!
Answer by SlyTrip · Mar 21, 2019 at 10:16 PM
Hi, I'm having the same issue. My banner is working as google is showing impressions, but I can't see the actual banner. I do have UI elements at the bottom, but would like the banner to overlay on them. Thanks in advance.
Answer by xetiro · Aug 16, 2019 at 03:44 AM
Same problem here :/
I am using Unity 2019.2.0f1 and Google Mobile Ads Unity Plugin v3.8.3.
I followed the official docs and implemented correctly, including the load callbacks.
The Logs shows that the Test Ads loaded correctly and the Show method is called according. In fact I can even touch the banner although I don't see it on the screen. Which means that the banner is on the correct position, just not visible.
If I remove all my UI stuff, I can finally see the banner. But its useless this way. It just shows that everything is working properly except the fact that the banner is being rendered behind the UI and not on the front of the UI.
I tried several experiments with camera Z depths, but nothing works.
Anyone had some progress on this problem?
Your answer
Follow this Question
Related Questions
adMob ads are black 2 Answers
admob banner ad not showing 0 Answers
Unity 5 error after importing APPLOVIN! (for android) 1 Answer
Trouble with closing Unity 5 ads 0 Answers