- Home /
Interstitial showing only once [AdMob]
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.
               Comment
              
 
               
              Answer by Elite_Champion · Jun 20, 2017 at 05:05 PM
Use this
  public void ShowVideo()
     {
 #if UNITY_EDITOR
         Debug.Log("Unable to play ad from PC");
 #elif UNITY_ANDROID
         if (Admob.Instance().isInterstitialReady())
             Admob.Instance().showInterstitial();
 
          else
         {
             Admob.Instance().loadInterstitial();
             Admob.Instance().showInterstitial();
         }
 #endif
 
     }
if you load and imidiatly show it will works ? im not sure about it --- edit ok actually its just works!! tnxxxxx!!!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                