I am having problems with Admob interstitial ads on android. I am using the GoogleMobileAdsDemoScript from [here][1]. I changed it up a bit and deleted things I don´t need. I don´t want to paste the whole thing here so here is my RequestInterstitial().
public void RequestInterstitial()
{
// These ad units are configured to always serve test ads.
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "Don´t want to share this";
#elif UNITY_IPHONE
string adUnitId = "INSERT_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
this.interstitial = new InterstitialAd(adUnitId);
// Register for ad events.
this.interstitial.OnAdLoaded += this.HandleInterstitialLoaded;
this.interstitial.OnAdFailedToLoad += this.HandleInterstitialFailedToLoad;
this.interstitial.OnAdOpening += this.HandleInterstitialOpened;
this.interstitial.OnAdClosed += this.HandleInterstitialClosed;
this.interstitial.OnAdLeavingApplication += this.HandleInterstitialLeftApplication;
// Load an interstitial ad.
this.interstitial.LoadAd(this.CreateAdRequest());
}
and here is the showinterstitial method.
public void ShowInterstitial()
{
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
}
else
{
MonoBehaviour.print("Interstitial is not ready yet");
}
}
Here I am calling the interstitial ad.
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "ObstaclesLeft" || other.gameObject.tag == "ObstaclesRight")
{
Die();
}
}
void Die() //OnTriggerEnter
{
GoogleMobileAdsDemoScript.Instance.RequestInterstitial();
GoogleMobileAdsDemoScript.Instance.ShowInterstitial();
menuPanel.gameObject.SetActive(true);
startPanel.gameObject.SetActive(false);
fadeInPanel.gameObject.SetActive(false);
Time.timeScale = 0;
}
I am in fact getting the console message ("Dummy ShowInterstitial") but when I run the game on my phone the ad doesn´t show up even if I call the method when the game starts or something. I have that feeling like I am missing something since I only followed [that][2] tutorial and that too is a bit outdated
If there is a possibility that there is just no ads available at the time for like couple hours now how do I use the test ads instead?
[1]: https://github.com/googleads/googleads-mobile-unity/releases
[2]: https://www.youtube.com/watch?v=2hX9hnXuy2Y
↧