コード例 #1
0
 public void ShowRewardedVideo()
 {
     Debug.Log("touch video button -------------");
     if (ad.isRewardedVideoReady())
     {
         ad.showRewardedVideo();
         ad.loadRewardedVideo(videoID);
     }
     else
     {
         ad.loadRewardedVideo(videoID);
     }
 }
コード例 #2
0
        public void ShowRewarded(Action <bool> endCallback, Action showCallback = null)
        {
            if (Shown)
            {
                return;
            }

#if !UNITY_EDITOR
            Shown = true;
#endif

            Debug.Log("Rewarded Ad request sending...");

#if UNITY_ANDROID
            string adId = testMode ? _testAds[2].id : androidAds[2].id;
#elif UNITY_IPHONE
            string adId = testMode? _testAds[2].id : iosAds[2].id;
#else
            string adId = "unexpected_platform";
#endif
            _lastRewardedVideoEndCallback  = endCallback;
            _lastRewardedVideoShowCallback = showCallback;


            Debug.Log("Rewarded Ad request sent.");

#if UNITY_EDITOR
            OnRewardVideoEvent("onAdLoaded", null);
            OnRewardVideoEvent("onAdOpened", null);
            OnRewardVideoEvent("onRewarded", null);
            OnRewardVideoEvent("onAdClosed", null);
#else
            _admob.loadRewardedVideo(adId);
#endif
        }
コード例 #3
0
 public void ShowRewardedVideo()
 {
     if (ad.isRewardedVideoReady())
     {
         ad.showRewardedVideo();
     }
     else
     {
         ad.loadRewardedVideo("ca-app-pub-2706666117164991/6051402869");
     }
 }
コード例 #4
0
 public void ShowVideoAd()
 {
     if (_ad.isRewardedVideoReady())
     {
         _ad.showRewardedVideo();
     }
     else
     {
         _ad.loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
     }
 }
コード例 #5
0
 public void ShowAdsVideo()
 {
     if (Ad.isRewardedVideoReady())
     {
         Ad.showRewardedVideo();
     }
     else
     {
         Ad.loadRewardedVideo(IdVideo);
     }
 }
コード例 #6
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(120, 0, 100, 60), "showInterstitial"))
        {
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(240, 0, 100, 60), "showRewardVideo"))
        {
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                //ad.loadRewardedVideo("ca-app-pub-3120877784109998/4714341465");
                ad.loadRewardedVideo("ca-app-pub-4622924889224894/8984406965");
            }
        }
        if (GUI.Button(new Rect(0, 100, 100, 60), "showbanner"))
        {
            Admob.Instance().showBannerRelative(AdSize.SmartBanner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(120, 100, 100, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 0, 300);
        }
        if (GUI.Button(new Rect(240, 100, 100, 60), "removebanner"))
        {
            Admob.Instance().removeBanner();
        }
        string nativeBannerID = "ca-app-pub-6908989844804937/5541215009";//

        // string nativeBannerID = "ca-app-pub-3940256099942544/2562852117";//google
        if (GUI.Button(new Rect(0, 200, 100, 60), "showNative"))
        {
            Admob.Instance().showNativeBannerRelative(new AdSize(320, 120), AdPosition.BOTTOM_CENTER, 0, nativeBannerID);
        }
        if (GUI.Button(new Rect(120, 200, 100, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(320, 120), 0, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(240, 200, 100, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #7
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(120, 0, 100, 60), "showInterstitial"))
        {
            Debug.Log("touch inst button -------------");
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial(interstitialID);
            }
        }
        if (GUI.Button(new Rect(240, 0, 100, 60), "showRewardVideo"))
        {
            Debug.Log("touch video button -------------");
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo(videoID);
            }
        }
        if (GUI.Button(new Rect(0, 100, 100, 60), "showbanner"))
        {
            Admob.Instance().showBannerRelative(bannerID, AdSize.SMART_BANNER, AdPosition.BOTTOM_CENTER);
        }
        if (GUI.Button(new Rect(120, 100, 100, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(bannerID, AdSize.BANNER, 20, 220, "mybanner");
        }
        if (GUI.Button(new Rect(240, 100, 100, 60), "removebanner"))
        {
            Admob.Instance().removeBanner();
            Admob.Instance().removeBanner("mybanner");
        }

        if (GUI.Button(new Rect(0, 200, 100, 60), "showNative"))
        {
            Admob.Instance().showNativeBannerRelative(nativeBannerID, new AdSize(320, 280), AdPosition.BOTTOM_CENTER);
        }
        if (GUI.Button(new Rect(120, 200, 100, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(nativeBannerID, new AdSize(-1, 132), 0, 300);
        }
        if (GUI.Button(new Rect(240, 200, 100, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #8
0
ファイル: admobdemo.cs プロジェクト: iancawood/BubbleHellGame
    void OnGUI()
    {
        if (GUI.Button(new Rect(120, 0, 100, 60), "showInterstitial"))
        {
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(240, 0, 100, 60), "showRewardVideo"))
        {
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("ca-app-pub-3940256099942544/xxxxxxxxxxxx");
            }
        }
        if (GUI.Button(new Rect(0, 100, 100, 60), "showbanner"))
        {
            Admob.Instance().showBannerRelative(AdSize.SmartBanner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(120, 100, 100, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 0, 300);
        }
        if (GUI.Button(new Rect(240, 100, 100, 60), "removebanner"))
        {
            Admob.Instance().removeBanner();
        }

        string nativeBannerID = "ca-app-pub-3940256099942544/2562852117";//google

        if (GUI.Button(new Rect(0, 200, 100, 60), "showNative"))
        {
            Admob.Instance().showNativeBannerRelative(new AdSize(320, 120), AdPosition.BOTTOM_CENTER, 0, nativeBannerID);
        }
        if (GUI.Button(new Rect(120, 200, 100, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(320, 120), 0, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(240, 200, 100, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #9
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(120, 0, 200, 80), "showInterstitial显示间隙"))
        {
            Debug.Log("touch inst button -------------");
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(440, 0, 200, 80), "showRewardVideo显示奖励视频"))
        {
            Debug.Log("touch video button -------------");
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo(videoID);
            }
        }
        if (GUI.Button(new Rect(0, 100, 200, 60), "showbanner横幅"))
        {
            Admob.Instance().showBannerRelative(AdSize.SmartBanner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(220, 100, 200, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 20, 300);
        }
        if (GUI.Button(new Rect(440, 100, 200, 60), "removebanner删除横幅"))
        {
            Admob.Instance().removeBanner();
        }

        if (GUI.Button(new Rect(0, 200, 200, 60), "showNative(本地人)"))
        {
            Admob.Instance().showNativeBannerRelative(new AdSize(320, 100), AdPosition.BOTTOM_CENTER, 0, nativeBannerID);
        }
        if (GUI.Button(new Rect(220, 200, 200, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(-1, 132), 20, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(440, 200, 200, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #10
0
    void onRewardedVideoEvent(string eventName, string msg)
    {
        LoadingBlockCtrl.Hide();
        Debug.Log("handler onRewardedVideoEvent---" + eventName + "  rewarded: " + msg);
        switch (eventName)
        {
        case "onAdFailedToLoad":
            if (showRewardedVideoLoading)
            {
                if (reloadTimes-- > 0)
                {
                    LoadingBlockCtrl.Show();
                    ad.loadRewardedVideo("ca-app-pub-4618478478287634/9895676018");
                }
                else
                {
                    ConfirmCtrl.Show("没有找到可以播放的广告,是否继续看广告?\n(Wifi不行可以切换4G试试)\n(也可以尝试断开重连下Wifi)", () => {
                        reloadTimes = 1;
                        LoadingBlockCtrl.Show();
                        ad.loadRewardedVideo("ca-app-pub-4618478478287634/9895676018");
                    }, null, "要看", "不看");
                }
            }
            break;

        case "onAdLoaded":
            ad.showRewardedVideo();
            SendEvent("RewardedVideoLoaded", DbManager.Instance.HostData.Lv.ToString());
            break;

        case "onRewarded":
            if (rewardedVideoCallback != null)
            {
                rewardedVideoCallback();
                SendEvent("EndRewardedVideo", DbManager.Instance.HostData.Lv.ToString());
            }
            break;
        }
    }
コード例 #11
0
 public void initAds()
 {
     Ad = Admob.Instance();
     // Delegate event harus yg paling awal
     Ad.rewardedVideoEventHandler += VideoEventHandler;
     // kemudian initialize id app
     Ad.initSDK(IdApp);
     // kemudian baru initialize id banner/inter/video/native banner
     Ad.initAdmob(IdBanner, IdIntertisial);
     // terakhir Load Ads
     Ad.loadRewardedVideo(IdVideo);
     Ad.loadInterstitial();
 }
コード例 #12
0
    public void ShowRewardVideo(bool wait = false)
    {
        if (UTIL.appPurchased == 1)
        {
            return;
        }

        Debug.Log("touch video button -------------");
        if (ad.isRewardedVideoReady())
        {
            /*show ad randomly when come back to main menu*/
            int rand = Random.Range(0, 20);
            if (!wait || rand > 16)
            {
                ad.showRewardedVideo();
            }
        }
        else
        {
            ad.loadRewardedVideo(videoID);
        }
    }
コード例 #13
0
 void InitAdmob()
 {
     _ad = Admob.Instance();
     _ad.interstitialEventHandler  += OnInterstitialEvent;
     _ad.rewardedVideoEventHandler += OnRewardedVideoEvent;
     _ad.initAdmob("ca-app-pub-3940256099942544/2934735716", "ca-app-pub-3940256099942544/4411468910");//all id are admob test id,change those to your
     _ad.loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
     //ad.setTesting(true);//show test ad
     _ad.setGender(AdmobGender.MALE);
     //string[] keywords = { "game", "crash", "male game" };
     //  ad.setKeywords(keywords);//set keywords for ad
     Debug.Log("admob inited -------------");
 }
コード例 #14
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(60, 0, 200, 120), "showInterstitial"))
        {
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(300, 0, 200, 120), "showRewardVideo"))
        {
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
            }
        }
        if (GUI.Button(new Rect(60, 150, 200, 120), "showbanner"))
        {
            Admob.Instance().showBannerRelative(AdSize.SmartBanner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(300, 150, 200, 120), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 20, 300);
        }
        if (GUI.Button(new Rect(60, 300, 200, 120), "removebanner"))
        {
            Admob.Instance().removeBanner();
        }
        string nativeBannerID = "ca-app-pub-3940256099942544/2934735716";

        if (GUI.Button(new Rect(300, 300, 200, 120), "showNative"))
        {
            Admob.Instance().showNativeBannerRelative(new AdSize(320, 120), AdPosition.BOTTOM_CENTER, 0, nativeBannerID);
        }
        if (GUI.Button(new Rect(60, 450, 200, 120), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(320, 120), 20, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(300, 450, 200, 120), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #15
0
 public void ShowRewardedAd()
 {
     //PleaseWait.SetActive(true);
     Debug.Log("touch video button -------------");
     if (ad.isRewardedVideoReady())
     {
         //RewardedButton.SetActive(false);
         ad.showRewardedVideo();
         rewardBasedVideo.OnAdRewarded += HandleOnAdRewarded;
     }
     else
     {
         ad.loadRewardedVideo(videoID);
     }
 }
コード例 #16
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 60), "initadmob"))
        {
            Admob ad = Admob.Instance();

            ad.initAdmob("YOUR_VALUE_HERE", "YOUR_VALUE_HERE");

            //   ad.setTesting(true);
        }
        if (GUI.Button(new Rect(120, 0, 100, 60), "showInterstitial"))
        {
            Admob ad = Admob.Instance();
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(240, 0, 100, 60), "showRewardVideo"))
        {
            Admob ad = Admob.Instance();
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("YOUR_VALUE_HERE");
            }
        }
        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.SmartBanner, 0, 30);
        }
        if (GUI.Button(new Rect(240, 300, 100, 60), "hidebanner"))
        {
            Admob.Instance().removeBanner();
        }
    }
コード例 #17
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 60), "initadmob"))
        {
            Admob ad = Admob.Instance();

            ad.initAdmob("ca-app-pub-3940256099942544/2934735716", "ca-app-pub-3940256099942544/4411468910");

            //   ad.setTesting(true);
        }
        if (GUI.Button(new Rect(120, 0, 100, 60), "showInterstitial"))
        {
            Admob ad = Admob.Instance();
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
        }
        if (GUI.Button(new Rect(240, 0, 100, 60), "showRewardVideo"))
        {
            Admob ad = Admob.Instance();
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("ca-app-pub-3940256099942544/xxxxxxxxxxx");
            }
        }
        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.SmartBanner, 0, 30);
        }
        if (GUI.Button(new Rect(240, 300, 100, 60), "hidebanner"))
        {
            Admob.Instance().removeBanner();
        }
    }
コード例 #18
0
    void Start()
    {
        Admob.Instance().bannerEventHandler        += onBannerEvent;
        Admob.Instance().interstitialEventHandler  += onInterstitialEvent;
        Admob.Instance().rewardedVideoEventHandler += onRewardedVideoEvent;

        Admob ad = Admob.Instance();

        ad.initAdmob("app id", "app id");         // See it in your admob account for particular app. Get these ids from Admob account.

        int choose = Random.Range(0, 3);

        // Randomly selection of what to display.......
        switch (choose)
        {
        case 0:                         // Full Screen Ads...
            ad = Admob.Instance();
            if (ad.isInterstitialReady())
            {
                ad.showInterstitial();
            }
            else
            {
                ad.loadInterstitial();
            }
            break;

        case 1:                         // Rewarded Videos
            ad = Admob.Instance();
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("ca-app-pub-3940256099942544/xxxxxxxxxxx");                                 // Provide your Id here...
            }
            break;

        case 2:                         //  Banner Ads
            Admob.Instance().showBannerRelative(AdSize.Banner, AdPosition.BOTTOM_CENTER, 0);
            break;
        }
    }
コード例 #19
0
 void loadRewardAds()
 {
     ad.loadRewardedVideo(admob_rewardID_fy);                //all id are admob test id,change those to your
 }
コード例 #20
0
 /// <summary>
 /// It will load rewarded video before showing,so video will be ready to show
 /// </summary>
 void LoadRewardedVideo()
 {
     ad.loadRewardedVideo(videoID);
 }
コード例 #21
0
 public static void DoRequestAdMob_RewardedVideo()
 {
     _pAdmob.loadRewardedVideo(const_strAdmobID_Rewarded);
     _pAdmob.setTesting(true);
 }