- Home /
deactivate script for period of time after script is used.
Hello. Is there a way to make my admob script deactivate for 4 minutes (240 seconds) after i use it. This is because i dont want the users to be shown ads constantly. I have a script below which needs adjusting. Thanks in advance!
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using GoogleMobileAds.Api; using System;
public class admob_ads : MonoBehaviour
{
private InterstitialAd interstitial;
string appId;
string adUnitId;
bool shoed;
public bool isTest = true;
private void Awake()
{
shoed = false;
if (isTest)
{
appId = "ca-app-pub-3940256099942544/103317312"; //Google admob test ID
}
else
{
appId = ""; // My app ID (not visible for security reasons)
}
MobileAds.Initialize(appId);
}
private void Start()
{
reqint();
}
private void reqint()
{
adUnitId = ""; //Interstitial ad ID
interstitial = new InterstitialAd(adUnitId);
AdRequest request = new AdRequest.Builder().Build();
interstitial.LoadAd(request);
}
public void Retry() //The part which makes it when i click retry an advert is shown
{
if (!shoed)
{
shoed = true;
Debug.Log("Ads Show");
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
}
}
Comment