- Home /
How to load custom banner ad if admob ad not loaded unity
I'm trying to load custom banner ad (own other games banner ad) if admob banner ad not loaded and destroy custom ad when banner ad is loaded. I wrote a code but it's not working.. here is code. public class AdScript : MonoBehaviour {
private BannerView bannerView;
void Start ()
{
this.showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-9238312914970318/8415382856";
bannerView = new BannerView(adID, AdSize.SmartBanner, AdPosition.Bottom);
bannerView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
bannerView.OnAdLoaded += HandleOnAdLoaded;
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
}
public void HandleOnAdLoaded(object sender, EventArgs args)
{
print("HandleAdLoaded event received");
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
print("HandleFailedToReceiveAd event received with message: "
+ args.Message);
// writing custom ad code here.. if admob banner ad not loaded
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612172228im_/https://answers.unity.com/themes/thub/images/avi.jpg)