1
\$\begingroup\$

this is my first Unity project and I'm getting desperate for answers. I've been trying to get Admob to work using the official plugin. It's been giving me a ton of problems as I can't get the banner to show, despite me using nearly verbatim code as tutorials.

Here's my code:

using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api;

public class AdMobTest : MonoBehaviour {

BannerView banner;
InterstitialAd fullAdmob;

// Use this for initialization
void Start () {
    RequestBanner();
    ShowBanner();  
}


void RequestBanner()
{
    string bannerID = "Hiding my banner ID";
    banner = new BannerView(bannerID,AdSize.SmartBanner,AdPosition.Bottom);
    AdRequest adRequest = new AdRequest.Builder().Build();

    banner.LoadAd(adRequest);
}

public void ShowBanner()
{
    banner.Show();

}

public void RequestFull()
{
    string idFull = "hiding my banner ID";
    fullAdmob = new InterstitialAd(idFull);
    AdRequest adRequest = new AdRequest.Builder().Build();

    fullAdmob.LoadAd(adRequest);
}

public void ShowfullAds()
{
    if (fullAdmob.IsLoaded())
    {
        fullAdmob.Show();
        RequestFull();
    }
    else
    {
        RequestFull();
    }
}

// Update is called once per frame
void Update () {

}

I have a new 2D project setup with an empty scene and an "ad" game object, and a script added to that game object. I'm expecting something to show up on my phone's screen, but nothing is showing up. I know this may be a stupid question, but I've spent a ton of time on this, and I'm pretty new to this stuff. So please help me out!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.