コード例 #1
0
        public RewardedAd(string adUnitId)
        {
            this.client = GoogleMobileAdsClientFactory.BuildRewardedAdClient();
            client.CreateRewardedAd(adUnitId);

            this.client.OnAdLoaded += (sender, args) =>
            {
                if (this.OnAdLoaded != null)
                {
                    this.OnAdLoaded(this, args);
                }
            };

            this.client.OnAdFailedToLoad += (sender, args) =>
            {
                if (this.OnAdFailedToLoad != null)
                {
                    this.OnAdFailedToLoad(this, args);
                }
            };

            this.client.OnAdFailedToShow += (sender, args) =>
            {
                if (this.OnAdFailedToShow != null)
                {
                    this.OnAdFailedToShow(this, args);
                }
            };

            this.client.OnAdOpening += (sender, args) =>
            {
                if (this.OnAdOpening != null)
                {
                    this.OnAdOpening(this, args);
                }
            };

            this.client.OnAdClosed += (sender, args) =>
            {
                if (this.OnAdClosed != null)
                {
                    this.OnAdClosed(this, args);
                }
            };

            this.client.OnUserEarnedReward += (sender, args) =>
            {
                if (this.OnUserEarnedReward != null)
                {
                    this.OnUserEarnedReward(this, args);
                }
            };
        }
コード例 #2
0
        public RewardedAd(string adUnitId)
        {
            // GoogleMobileAdsClientFactory is not included in the compiled DLL due to
            // needing platform directives, so reflection is needed to call this method.
            var googleMobileAdsClientFactory = Type.GetType(
                "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp");
            var method = googleMobileAdsClientFactory.GetMethod(
                "BuildRewardedAdClient",
                BindingFlags.Static | BindingFlags.Public);

            client = (IRewardedAdClient)method.Invoke(null, null);
            client.CreateRewardedAd(adUnitId);

            client.OnAdLoaded += (sender, args) =>
            {
                if (OnAdLoaded != null)
                {
                    OnAdLoaded(this, args);
                }
            };

            client.OnAdFailedToLoad += (sender, args) =>
            {
                if (OnAdFailedToLoad != null)
                {
                    OnAdFailedToLoad(this, args);
                }
            };

            client.OnAdFailedToShow += (sender, args) =>
            {
                if (OnAdFailedToShow != null)
                {
                    OnAdFailedToShow(this, args);
                }
            };

            client.OnAdOpening += (sender, args) =>
            {
                if (OnAdOpening != null)
                {
                    OnAdOpening(this, args);
                }
            };

            client.OnAdClosed += (sender, args) =>
            {
                if (OnAdClosed != null)
                {
                    OnAdClosed(this, args);
                }
            };

            client.OnUserEarnedReward += (sender, args) =>
            {
                if (OnUserEarnedReward != null)
                {
                    OnUserEarnedReward(this, args);
                }
            };
        }
コード例 #3
0
        public RewardedAd(string adUnitId)
        {
            this.client   = MobileAds.GetClientFactory().BuildRewardedAdClient();
            this.adUnitId = adUnitId;
            this.isLoaded = false;
            client.CreateRewardedAd();

            this.client.OnAdLoaded += (sender, args) =>
            {
                this.isLoaded = true;
                if (this.OnAdLoaded != null)
                {
                    this.OnAdLoaded(this, args);
                }
            };

            this.client.OnAdFailedToLoad += (sender, args) =>
            {
                if (this.OnAdFailedToLoad != null)
                {
                    LoadAdError loadAdError = new LoadAdError(args.LoadAdErrorClient);
                    this.OnAdFailedToLoad(this, new AdFailedToLoadEventArgs()
                    {
                        LoadAdError = loadAdError
                    });
                }
            };

            this.client.OnAdFailedToPresentFullScreenContent += (sender, args) =>
            {
                if (this.OnAdFailedToShow != null)
                {
                    AdError adError = new AdError(args.AdErrorClient);

                    this.OnAdFailedToShow(this, new AdErrorEventArgs()
                    {
                        AdError = adError
                    });
                }
            };

            this.client.OnAdDidPresentFullScreenContent += (sender, args) =>
            {
                if (this.OnAdOpening != null)
                {
                    this.OnAdOpening(this, args);
                }
            };

            this.client.OnAdDidDismissFullScreenContent += (sender, args) =>
            {
                if (this.OnAdClosed != null)
                {
                    this.OnAdClosed(this, args);
                }
            };

            this.client.OnAdFailedToPresentFullScreenContent += (sender, args) =>
            {
                if (this.OnAdFailedToShow != null)
                {
                    AdError adError = new AdError(args.AdErrorClient);
                    this.OnAdFailedToShow(this, new AdErrorEventArgs()
                    {
                        AdError = adError
                    });
                }
            };

            this.client.OnAdDidRecordImpression += (sender, args) =>
            {
                if (this.OnAdDidRecordImpression != null)
                {
                    this.OnAdDidRecordImpression(this, args);
                }
            };

            this.client.OnUserEarnedReward += (sender, args) =>
            {
                if (this.OnUserEarnedReward != null)
                {
                    this.OnUserEarnedReward(this, args);
                }
            };

            this.client.OnPaidEvent += (sender, args) =>
            {
                if (this.OnPaidEvent != null)
                {
                    this.OnPaidEvent(this, args);
                }
            };
        }
コード例 #4
0
        public RewardedAd(string adUnitId)
        {
            this.client = MobileAds.GetClientFactory().BuildRewardedAdClient();
            client.CreateRewardedAd(adUnitId);

            this.client.OnAdLoaded += (sender, args) =>
            {
                if (this.OnAdLoaded != null)
                {
                    this.OnAdLoaded(this, args);
                }
            };

            this.client.OnAdFailedToLoad += (sender, args) =>
            {
                if (this.OnAdFailedToLoad != null)
                {
                    LoadAdError loadAdError = new LoadAdError(args.LoadAdErrorClient);
                    this.OnAdFailedToLoad(this, new AdFailedToLoadEventArgs()
                    {
                        LoadAdError = loadAdError,
                        Message     = loadAdError.GetMessage()
                    });
                }
            };

            this.client.OnAdFailedToShow += (sender, args) =>
            {
                if (this.OnAdFailedToShow != null)
                {
                    AdError adError = new AdError(args.AdErrorClient);

                    this.OnAdFailedToShow(this, new AdErrorEventArgs()
                    {
                        AdError = adError,
                        Message = adError.GetMessage()
                    });
                }
            };

            this.client.OnAdOpening += (sender, args) =>
            {
                if (this.OnAdOpening != null)
                {
                    this.OnAdOpening(this, args);
                }
            };

            this.client.OnAdClosed += (sender, args) =>
            {
                if (this.OnAdClosed != null)
                {
                    this.OnAdClosed(this, args);
                }
            };

            this.client.OnUserEarnedReward += (sender, args) =>
            {
                if (this.OnUserEarnedReward != null)
                {
                    this.OnUserEarnedReward(this, args);
                }
            };

            this.client.OnPaidEvent += (sender, args) =>
            {
                if (this.OnPaidEvent != null)
                {
                    this.OnPaidEvent(this, args);
                }
            };
        }