5

I am looking to integrate admob interstitial in Unity, i did it for banner but unable to find final solution for interstitial, any help would be appreciated.

I tied following links but it didn't work for Interstitial https://github.com/googleads/googleads-mobile-plugins

Please do not suggest any paid plugin as Prime31 etc.

lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
stack
  • 951
  • 3
  • 9
  • 23

5 Answers5

5

You can download the unity package from the google developer page here

trenki
  • 7,133
  • 7
  • 49
  • 61
3

If the free plugin doesn't suit your needs, you'll have to write your own native plugin or purchase on on the Asset Store. However, that plugin's README says it supports interstitials. Try following the instructions in the readme. If you already tried that and it didn't work, it would help if you tell us exactly what went wrong.

Taken from that readme:

Here is the minimal banner code to create an interstitial.

using GoogleMobileAds.Api;
...
// Initialize an InterstitialAd.
InterstitialAd interstitial = new InterstitialAd("MY_AD_UNIT_ID");
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);

Unlike banners, interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:

if (interstitial.IsLoaded()) {
  interstitial.Show();
}
sargunv
  • 2,548
  • 1
  • 13
  • 11
  • With regard to ad your carry him in a scene is to show it in another scene in another script ? – Vale Feb 08 '16 at 12:00
2

There's a done Unity Package for AdMob which I used in my android game, you can find it in here: http://forum.unity3d.com/threads/admob-unity-package-that-work-with-unity-3-2-above.173292

Make sure to go through the whole thread because it needs a bit of tuning to get it working perfectly with newer unity versions.

Little help about the app publisher id - look for page7 on the thread.

slavacademy
  • 676
  • 1
  • 9
  • 22
1

Here you go. Google's official Unity Plugin and they have code sample for Banner and Interstitial Ads.

King David
  • 139
  • 1
  • 9
Amalan Dhananjayan
  • 2,277
  • 1
  • 34
  • 47
1

try https://github.com/unity-plugins/Unity-Admob. I have success with this one.

and code is much more easy.

using UnityEngine;
using System.Collections;
using admob;
public class admobdemo : MonoBehaviour {

    // Use this for initialization
    void Start () {
        Admob.Instance().bannerEventHandler += onBannerEvent;
        Admob.Instance().interstitialEventHandler += onInterstitialEvent;
    }

    // Update is called once per frame
    void Update () {

    }
    void OnGUI(){
        if (GUI.Button (new Rect (0, 0, 100, 60), "initadmob")) {
            Admob ad = Admob.Instance();
             #if UNITY_IOS
            ad.initAdmob("ca-app-pub-27960454450664210/xxxxxxxxx", "ca-app-pub-279343530664210/xxxxxxxxxxx");
            #else 
            ad.initAdmob("ca-app-pub-27960454450664210/xxxxxxxxx", "ca-app-pub-279343530664210/xxxxxxxxxxx");
            #endif
         //   ad.setTesting(true);
        }
        if (GUI.Button(new Rect(120, 0, 100, 60), "showfull"))
        {
            Admob ad = Admob.Instance();
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(240, 100, 100, 60), "showbanner"))
        {
            Admob.Instance().showBannerRelative(AdSize.Banner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(240, 200, 100, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 0, 30);
        }
        if (GUI.Button(new Rect(240, 300, 100, 60), "hidebanner"))
        {
            Admob.Instance().removeBanner();
        }
    }
    void onInterstitialEvent(string eventName, string msg)
    {
        Debug.Log("handler onAdmobEvent---" + eventName + "   " + msg);
        if (eventName == AdmobEvent.onAdLoaded)
        {
            Admob.Instance().showInterstitial();
        }
    }
    void onBannerEvent(string eventName, string msg)
    {
        Debug.Log("handler onAdmobBannerEvent---" + eventName + "   " + msg);
    }
}
jobs
  • 36
  • 1