How to Show Admob interstitial ads more one time after Gameover?
using UnityEngine; using System.Collections; using GoogleMobileAds.Api;
public class AdManager : MonoBehaviour {
public static AdManager Instance{set;get;}
public string InterstitialId;
public string BannerId;
private BannerView bannerView;
private InterstitialAd interstitial;
public int gameoverToShowAd;
public static int gameoverCounter;
// Use this for initialization
private void Start () {
Instance = this;
DontDestroyOnLoad (gameObject);
bannerView = new BannerView (BannerId, AdSize.Banner, AdPosition.Bottom);
interstitial = new InterstitialAd (InterstitialId);
ShowBanner();
LoadVideo();
}
private void Update()
{
if(gameoverCounter == gameoverToShowAd)
{
ShowVideo();
gameoverCounter = 0;
}
}
public void LoadVideo() {
AdRequest request = new AdRequest.Builder ().Build ();
interstitial.LoadAd (request);
}
public void ShowVideo()
{
if (interstitial.IsLoaded())
interstitial.Show();
else
{
AdRequest request = new AdRequest.Builder().Build();
interstitial.LoadAd(request);
}
}
public void ShowBanner()
{
AdRequest request = new AdRequest.Builder ().Build ();
bannerView.LoadAd (request);
bannerView.Show ();
}
public void RemoveBanner()
{
bannerView.Hide ();
}
}
I just set 3 times Gameover to show admob interstitial ads, now just show one time, not every 3 gameover to show ads, please help, thanks!
Comment