This is my code:
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class InterstitialScript : MonoBehaviour
{
private InterstitialAd interstitial;
public static InterstitialScript instance;
void Awake()
{
instance = this;
MobileAds.Initialize(initStatus => { });
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
void Start()
{
//InterstitialScript = this;
MobileAds.Initialize(initStatus => { });
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
public void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-9471668556390079~8501400148";
#elif UNITY_IPHONE
string adUnitId = null;
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
if (interstitial.IsLoaded())
{
interstitial.LoadAd(request);
}
interstitial.Show();
}
void Update()
{
}
}
I get one of those Debug.Log thing errors, that looks like this:
Here's what is reads:
No Ad Loaded
UnityEngine.Debug:Log (object)
GoogleMobileAds.Unity.InterstitialClient:Show ()
GoogleMobileAds.Api.InterstitialAd:Show ()
InterstitialScript:RequestInterstitial () (at Assets/Scripts/InterstitialScript.cs:52)
GameOver:Continue () (at Assets/Scripts/GameOver.cs:41)
UnityEngine.EventSystems.EventSystem:Update () (at
Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)