Void Update. Only once.

Hi, I need to show an Insterticial Ad when the player is dead ussing this Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class aaa : MonoBehaviour {

	public GameObject GameOverSplash;

	void Update()
	{
		if(GameOverSplash.active)
		
	       {
		       EasyGoogleMobileAds.GetInterstitialManager().ShowInterstitial();
	       }
	}

}

An it works but the Script show a Ad every second. But when I use Void Start, It does not work.

I need to show the Ad only once.

Thanks for the help.

Have a good day.

Simply disable after you have called the function:

     void Update()
     {
         if(GameOverSplash.active)             
            {
                EasyGoogleMobileAds.GetInterstitialManager().ShowInterstitial();
                enabled = false ;
            }
     }

Or, use coroutines:

 IEnumerator Start()
 {
     yield return null ; // Wait one frame
     EasyGoogleMobileAds.GetInterstitialManager().ShowInterstitial();
 }

Instead of using an aaa.Update(), you can use GameOverSplash.OnEnable() method.

the simple way, like i always do, i make prefab and put some ads script inside that prefab and instantiate that prefab after enemy or player die… and destroy it around 0.1f…