This is probably a very easy question to answer, but for some reason, I can’t figure out what is wrong. I want my int showAd to decrease by one every time the Canvas1 is enabled. Here is code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdManager : MonoBehaviour {
//public bool dead;
public int showAd = 3;
public InterstitialAd interstitial;
public BannerView bannerView;
public bool canShowInt;
void Start () {
RequestBanner ();
RequestInterstitial ();
}
void Awake () {
DontDestroyOnLoad (this);
}
void Update () {
if (GameObject.Find ("Canvas1").GetComponent <Canvas> ().enabled == true) {
canShowInt = true;
} else {
canShowInt = false;
}
if (showAd == 0) {
showAd = 3;
}
}
void ShowInterstitial () {
if (canShowInt == true) {
showAd = showAd - 1;
if (showAd == 0) {
if (interstitial.IsLoaded ()) {
interstitial.Show ();
interstitial.Destroy ();
}
}
}
}