Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Repeat admob interstitial

$
0
0
`enter code here`hi, i have succede in producing a code for show up an AdMob at the death of my player, but i can't get along with the fact that, if i tap "Play again" and make #Game 2 and i die the AdMob don't want to show up even if i do more games, something strange has happens once time, i get back to the menu i start a new game and after immediatly show up an AdMob, but this happens only once. i did with both of codes with that Test code and the Real Code, all works, i get back to the test code but i can't solve, impost maybe not every death but something like 2-3 or 1 at 1 minut don't know. i want to show un Interstitial Ad, i'm getting crazy, thanks guys. m don't know why is looking like all is comments only this should be "//AdRequest request = new AdRequest.Builder().Build(); " public class AdScript : MonoBehaviour { bool hasShownAdOneTime; InterstitialAd interstitial; void Start() { RequestInterstitialAds(); } void Update() { if (GameManager.isGameOver) { if (!hasShownAdOneTime) { hasShownAdOneTime = true; Invoke("showInterstitialAd", 1.0f); } } } public void showInterstitialAd() { if (interstitial.IsLoaded()) { interstitial.Show(); Debug.Log("SHOW AD XXX"); } } private void RequestInterstitialAds() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/1033173712"; #elif UNITY_IOS string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = unexpected_platform"; #endif interstitial = new InterstitialAd(adUnitId); interstitial.OnAdClosed += Interstitial_OnAdClosed; //AdRequest request = new AdRequest.Builder().Build(); AdRequest request = new AdRequest.Builder() .AddTestDevice(AdRequest.TestDeviceSimulator) .AddTestDevice(SystemInfo.deviceUniqueIdentifier) .Build(); interstitial.LoadAd(request); Debug.Log("AD LOADED XXX"); } private void Interstitial_OnAdClosed(object sender, System.EventArgs e) { RequestInterstitialAds(); } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles