nabrozidhs / unity_admob_android

Basic Unity3D plugin for AdMob Google Play Services version.
MIT License
25 stars 12 forks source link

How do you hide interstitial #12

Closed giov507 closed 10 years ago

giov507 commented 10 years ago

Showing interstitial takes a lot of time, i want it to be ready so just when i want to show it just code showinterstitial. So how to hide it?

nabrozidhs commented 10 years ago

Have you tried calling RequestInterstitial() when you first load your level and show it at the end? That should give you plenty of time to load the ad.

giov507 commented 10 years ago

when i use requestInterstitial it loads and appear after it loads without calling it : /

nabrozidhs commented 10 years ago

That is weird... Are you sure you don't have a callback on InterstitialLoaded?

giov507 commented 10 years ago

Nope, what is the best practice?: Requesting at start then "ShowInterstitial" whenever I want? This is what I'm doing

void Start() {

    admob = GetComponent<AdMobPlugin>();
    admob.CreateBanner(AD_UNIT_ID, AdMobPlugin.AdSize.BANNER, false, INTERSTITIAL_ID, false);
    admob.RequestAd();
    admob.HideBanner();

                }

void Update() { if (endgame == true){ endgame = false; admob.RequestInterstitial(); admob.ShowInterstitial(); }

Pretty much

nabrozidhs commented 10 years ago

Why don't you request the interstitial when you create the banner? You'll be able to show it when you evaluate the true branch of your if statement.

HenrikPoulsen commented 10 years ago

It never shows for me if I don't call ShowInterstitial(), just using RequestInterstitial() won't show it.

I wouldn't recommend requesting the interstitial immediately before you show it. Because as you noticed if can take a while before the interstitial has been downloaded to the device. In my case I use RequestInterstitial() at the start of my game round, and then call ShowInterstitial() when the player is Game Over. That way it is very likely that the interstitial has been loaded successfully before I show it.

I have also added a bool which i set to true in the interstitial callback named interstitialLoaded which I then use when I want to show the interstitial: if(admob.interstitialLoaded) { admob.ShowInterstitial(); admob.interstitialLoaded = false; }

since I rather not show it at all if it is not ready to show when I want it too. Since I dont want it popping up 10-30 seconds later.

Summary:

  1. Call admob.RequestInterstitial() when the game round starts.
  2. Call admob.ShowInterstitial() when the game round ends and you know that the request is ready.
nabrozidhs commented 10 years ago

@DragonSpawn that was my first comment but I think @giov507 didn't understood me :(

giov507 commented 10 years ago

Okay After a few tweaks it worked! Thankyou so much for your fast answers!