Hello everyone. I have created an app about 2 months ago, and it's been doing really well lately so I'm trying to implement interstitials, but there's one problem. The interstitial only shows once per session.
Here's my code:
using UnityEngine;
using System.Collections;
using admob;
public class AdManager : MonoBehaviour {
public static AdManager Instance { set; get; }
public string bannerID = "ca-app-pub-xxxx";
public string interID = "ca-app-pub-xxxx/xxxx";
private void Start()
{
Instance = this;
DontDestroyOnLoad(gameObject);
#if UNITY_EDITOR
#elif UNITY_ANDROID
Admob.Instance().initAdmob(bannerID, interID);
Admob.Instance().loadInterstitial();
#endif
}
public void ShowBanner()
{
#if UNITY_EDITOR
#elif UNITY_ANDROID
Admob.Instance().showBannerRelative(AdSize.Banner, AdPosition.TOP_CENTER, 0);
#endif
}
public void ShowVideo()
{
#if UNITY_EDITOR
#elif UNITY_ANDROID
if (Admob.Instance().isInterstitialReady())
{
Admob.Instance().showInterstitial();
}
#endif
}
}
I'd like to play an interstitial video every 5 times a button gets pressed in my game. Currently I have this code:
public void MyMethod(){
if (AdCount > 0)
{
AdCount--;
}
else if (AdCount == 0)
{
AdManager.Instance.ShowVideo();
AdCount = 5;
}
}
How could I make it so that a new interstitial is shown after the counter reaches 0?
Thanks in advance.
↧