コード例 #1
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();
            }
        }
        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(AdSize.SmartBanner, AdPosition.BOTTOM_CENTER, 0);
        }
        if (GUI.Button(new Rect(120, 100, 100, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 20, 300);
        }
        if (GUI.Button(new Rect(240, 100, 100, 60), "removebanner"))
        {
            Admob.Instance().removeBanner();
        }

        if (GUI.Button(new Rect(0, 200, 100, 60), "showNative"))
        {
            Admob.Instance().showNativeBannerRelative(new AdSize(320, 100), AdPosition.BOTTOM_CENTER, 0, nativeBannerID);
        }
        if (GUI.Button(new Rect(120, 200, 100, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(-1, 132), 20, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(240, 200, 100, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #2
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, 130, 60), "showRewardVideo"))
        {
            if (ad.isRewardedVideoReady())
            {
                ad.showRewardedVideo();
            }
            else
            {
                ad.loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
            }
        }
        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, 130, 60), "showbannerABS"))
        {
            Admob.Instance().showBannerAbsolute(AdSize.Banner, 20, 300);
        }
        if (GUI.Button(new Rect(270, 100, 100, 60), "removebanner"))
        {
            Admob.Instance().removeBanner();
        }

        string nativeBannerID = "ca-app-pub-3940256099942544/2934735716";

        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, 130, 60), "showNativeABS"))
        {
            Admob.Instance().showNativeBannerAbsolute(new AdSize(320, 120), 20, 300, nativeBannerID);
        }
        if (GUI.Button(new Rect(270, 200, 100, 60), "removeNative"))
        {
            Admob.Instance().removeNativeBanner();
        }
    }
コード例 #3
0
 public void ShowRewardedVideo()
 {
     Debug.Log("touch video button -------------");
     if (ad.isRewardedVideoReady())
     {
         ad.showRewardedVideo();
         ad.loadRewardedVideo(videoID);
     }
     else
     {
         ad.loadRewardedVideo(videoID);
     }
 }
コード例 #4
0
 /// <summary>
 /// Shows rewarded video
 /// </summary>
 public void ShowRewardedVideo()
 {
     Debug.Log("pressed video button -------------");
     if (ad.isRewardedVideoReady())
     {
         ad.showRewardedVideo();
     }
     else
     {
         //you can show text on ui with message like "video is not available"
         LoadRewardedVideo();
     }
 }
コード例 #5
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);
        }
    }
コード例 #6
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);
     }
 }
コード例 #7
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();
        }
    }
コード例 #8
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();
        }
    }
コード例 #9
0
 public static void StartRewardedVideo(System.Action callback, bool showLoading = true)
 {
     rewardedVideoCallback    = callback;
     showRewardedVideoLoading = showLoading;
     if (ad.isRewardedVideoReady())
     {
         ad.showRewardedVideo();
     }
     else
     {
         reloadTimes = 1;
         if (showRewardedVideoLoading)
         {
             LoadingBlockCtrl.Show();
         }
         ad.loadRewardedVideo("ca-app-pub-4618478478287634/9895676018");
     }
 }
コード例 #10
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;
        }
    }