Hello,
im trying to add a google interstitial at my project but somehow it doesnt show up.
Banners showing up without a problem,but for test purposes i deactivted the banner.
Test script attached on my main camera :
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdScript : MonoBehaviour {
public bool showint;
// Use this for initialization
void Start () {
RequestInterstitialAds ();
//showBannerAd();
showint = true;
}
private void showBannerAd()
{
string adID = "myadid";
//Testing
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("9C99086DFF14F4B8") // My test device.
.Build();
// normal
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Top);
bannerAd.LoadAd(request);
}
// Update is called once per frame
void Update () {
if (showint == true) {
showInterstitialAD ();
showint = false;
}
}
//AD
InterstitialAd interstitial;
private void RequestInterstitialAds()
{
string adID = "myADID";
#if UNITY_ANDROID
string adUnitId = adID;
#elif UNITY_IOS
string adUnitId = adID;
#else
string adUnitId = adID;
#endif
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
//Test
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("9C99086DFF14F4B8") // My test device.
.Build();
//normal
//AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
}
public void showInterstitialAD(){
if (interstitial.IsLoaded ()) {
interstitial.Show ();
}
}
}
I also tried to add it to the normal game,after u died and before u get to the highscore scene.
public void tohighscore(){
RequestInterstitialAds();
showInterstitialAD ();
SceneManager.LoadScene ("Highscore", LoadSceneMode.Single);
}
Theres a button which activates the method “tohighscore”. Doesnt work aswell…