android Unity游戏中集成 Admob集成全屏广告教程

[size=small]android Unity游戏中集成  Admob集成全屏广告教程[/size]


怎么在Unity应用里面集成Admob全屏广告?下面的Unity3d里面添加admob广告的代码
    using admob;
    ...
    Admob.Instance().initAdmob("admob banner id", "admob interstitial id");//initAdmob just need call once,if you called when create banner ,you not need call any more
    Admob.Instance().loadInterstitial();

和横幅广告不同,全屏广告需要先加载,等加载完成后在合适的时间点展示广告

    if (Admob.Instance().isInterstitialReady()) {
      Admob.Instance().showInterstitial();
    }

你也可以在unity3d里面监听并处理所有admob广告事件

下面是一个处理全屏广告事件的例子,我们在收到广告的时候就展示广告
    using admob;
    ...
    Admob.Instance().interstitialEventHandler += onInterstitialEvent;
    ...
    void onInterstitialEvent(string eventName, string msg)
    {
        Debug.Log("handler onAdmobEvent---" + eventName + "   " + msg);
        if (eventName == AdmobEvent.onAdLoaded)
        {
            Admob.Instance().showInterstitial();
        }
    }



Admob Unity Plugin 官方地址 https://github.com/unity-plugins/Unity-Admob

猜你喜欢

转载自dream01.iteye.com/blog/2270036