void Start() { AdOptions adOptions = new AdOptionsBuilder() .SetChannelId(GlobleSettings.GetChannelId) .SetAutoLoadNext(GlobleSettings.IsAutoload) .build(); rewardVideo = new RewardVideoAd(GlobleSettings.GetAppID, GlobleSettings.GetRewardVideoUnitID, adOptions); rewardVideo.OnAdLoaded += HandleRewardVideoLoaded; rewardVideo.OnAdFailedToLoad += HandleRewardVideoFailedToLoad; rewardVideo.OnAdStarted += HandleRewardVideoStart; rewardVideo.OnAdClicked += HandleRewardVideoClicked; rewardVideo.OnAdRewarded += HandleRewardVideoRewarded; rewardVideo.OnAdClosed += HandleRewardVideoClosed; interstitial = new InterstitialAd(GlobleSettings.GetAppID, GlobleSettings.GetInterstitialUnitID, adOptions); interstitial.OnAdLoaded += HandleInterstitialLoaded; interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad; interstitial.OnAdStarted += HandleInterstitialStart; interstitial.OnAdClicked += HandleInterstitialClicked; interstitial.OnAdClosed += HandleInterstitialClosed; BannerViewOptions bannerOptions = new BannerViewOptionsBuilder() .setAdPosition(AdPosition.BOTTOM) .setChannelID(GlobleSettings.GetChannelId) .setBannerSize(BannerAdSize.BANNER_AD_SIZE_320x50) .Build(); bannerView = new BannerView(GlobleSettings.GetAppID, GlobleSettings.GetBannerUnitID, bannerOptions); bannerView.OnAdLoaded += HandleBannerAdLoaded; bannerView.OnAdFailedToLoad += HandleBannerAdFailedToLoad; bannerView.OnAdClicked += HandleBannerClicked; }
public void OnRewardVideoAdLoad(RewardVideoAd ad) { Debug.Log("OnRewardVideoAdLoad"); this.example.information.text = "OnRewardVideoAdLoad"; ad.SetRewardAdInteractionListener( new RewardAdInteractionListener(this.example)); this.example.rewardAd = ad; }
/// <summary> /// Show the reward Ad. /// </summary> public void ShowRewardAd() { if (this.rewardAd == null) { Debug.LogError("请先加载广告"); this.information.text = "请先加载广告"; return; } this.rewardAd.ShowRewardVideoAd(); #if UNITY_IOS #else this.rewardAd = null; #endif }
/// <summary> /// Dispose the reward Ad. /// </summary> public void DisposeAds() { #if UNITY_IOS if (this.rewardAd != null) { this.rewardAd.Dispose(); this.rewardAd = null; } if (this.fullScreenVideoAd != null) { this.fullScreenVideoAd.Dispose(); this.fullScreenVideoAd = null; } if (this.bannerAd != null) { this.bannerAd.Dispose(); this.bannerAd = null; } if (this.intersititialAd != null) { this.intersititialAd.Dispose(); this.intersititialAd = null; } #else if (this.rewardAd != null) { this.rewardAd = null; } if (this.fullScreenVideoAd != null) { this.fullScreenVideoAd = null; } if (this.mBannerAd != null) { this.mBannerAd = null; } if (this.mIntersititialAd != null) { this.mIntersititialAd = null; } #endif }
/// <summary> /// Load the reward Ad. /// </summary> public void LoadRewardAd(int direction) { var rit = ""; #if UNITY_IOS if (this.rewardAd != null) { this.rewardAd.Dispose(); this.rewardAd = null; } if (direction == 1) { rit = "900546319"; } else { rit = "900546826"; } #else if (this.rewardAd != null) { Debug.LogError("广告已经加载"); this.information.text = "广告已经加载"; return; } if (direction == 1) { rit = "901121430"; } else { rit = "901121365"; } #endif var adSlot = new AdSlot.Builder() .SetCodeId(rit) .SetImageAcceptedSize(1080, 1920) //.SetRewardName("金币") // rewardname ,the data filled in by the platform shall prevail //.SetRewardAmount(3) // rewardamount ,the data filled in by the platform shall prevail .SetUserID("user123") // 用户id,必传参数 .SetMediaExtra("media_extra") // 附加参数,可选 .SetOrientation(AdOrientation.Horizontal) // 必填参数,期望视频的播放方向 .Build(); this.AdNative.LoadRewardVideoAd( adSlot, new RewardVideoAdListener(this)); }
void Start() { AdOptions adOptions = new AdOptionsBuilder() .SetChannelId(GlobleSettings.GetChannelId) .SetAutoLoadNext(GlobleSettings.IsAutoload) .build(); rewardVideo = new RewardVideoAd(GlobleSettings.GetAppID, GlobleSettings.GetRewardVideoUnitID, adOptions); rewardVideo.OnAdLoaded += HandleRewardVideoLoaded; rewardVideo.OnAdFailedToLoad += HandleRewardVideoFailedToLoad; rewardVideo.OnAdStarted += HandleRewardVideoStart; rewardVideo.OnAdClicked += HandleRewardVideoClicked; rewardVideo.OnAdRewarded += HandleRewardVideoRewarded; rewardVideo.OnAdClosed += HandleRewardVideoClosed; interstitial = new InterstitialAd(GlobleSettings.GetAppID, GlobleSettings.GetInterstitialUnitID, adOptions); interstitial.OnAdLoaded += HandleInterstitialLoaded; interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad; interstitial.OnAdStarted += HandleInterstitialStart; interstitial.OnAdClicked += HandleInterstitialClicked; interstitial.OnAdClosed += HandleInterstitialClosed; }
/// <summary> /// Dispose the reward Ad. /// </summary> public void DisposeAds() { #if UNITY_IOS if (this.rewardAd != null) { this.rewardAd.Dispose(); this.rewardAd = null; } if (this.fullScreenVideoAd != null) { this.fullScreenVideoAd.Dispose(); this.fullScreenVideoAd = null; } if (this.nativeFeedAd != null) { this.nativeFeedAd.Dispose(); this.nativeFeedAd = null; } if (this.mExpressFeedad != null) { this.mExpressFeedad.Dispose(); this.mExpressFeedad = null; } //if (this.intersititialAd != null) //{ // this.intersititialAd.Dispose(); // this.intersititialAd = null; //} if (this.expressRewardAd != null) { this.expressRewardAd.Dispose(); this.expressRewardAd = null; } if (this.expressFullScreenVideoAd != null) { this.expressFullScreenVideoAd.Dispose(); this.expressFullScreenVideoAd = null; } if (this.iExpressBannerAd != null) { this.iExpressBannerAd.Dispose(); this.iExpressBannerAd = null; } #else if (this.rewardAd != null) { this.rewardAd = null; } if (this.fullScreenVideoAd != null) { this.fullScreenVideoAd = null; } if (this.mNativeAd != null) { this.mNativeAd = null; } if (this.mExpressFeedad != null) { NativeAdManager.Instance().DestoryExpressAd(mExpressFeedad.handle); mExpressFeedad = null; } if (this.mExpressBannerAd != null) { NativeAdManager.Instance().DestoryExpressAd(mExpressBannerAd.handle); mExpressBannerAd = null; } if (this.mExpressInterstitialAd != null) { NativeAdManager.Instance().DestoryExpressAd(mExpressInterstitialAd.handle); mExpressInterstitialAd = null; } #endif }