I had some programming problems in unity with C #. I'm trying to request interstitial AD when I launch the game, so I can show it when the player died 5 times. The problem is that when I get to the fifth death, the announcement will not be shown. and when I try to request an ad when the level begins, it becomes lagging and still does not appear.
This is my code. Seems right.
void Update(){
if (clicks >= 5) {
RequestInterstitial();
Debug.Log("Got 5 clicks");
if (interstitial.IsLoaded()){
Debug.Log("interstitial loaded");
interstitial.Show();
clicks = 0;
}
}
}
EDIT: After changing my code, I now get the error message:
NullReferenceException: the reference to the object is not installed in the ADS.ADMobsGameplay.Update () object instance (in Assets / Scripts / ADS / ADMobsGameplay.cs: 28)
Line 28 corresponds if (interstitial.IsLoaded()){
in the following code:
void Update(){
if (clicks >= 5) {
Debug.Log("Got 5 clicks");
if (interstitial.IsLoaded()){
Debug.Log("interstitial loaded");
interstitial.Show();
clicks = 0;
}else{
RequestInterstitial();
}
}
}