Migrating from AdMob to Yandex mediation
Warning.
This is an archived version of the documentation. Actual documentation for all platforms can be found here.
To replace AdMob ads with Yandex Ads mediation on Unity, make the following changes to your code.
Integrating the SDK
Libraries are distributed via the Unity Play Services Resolver library. Add the following plugin resource to the project:
AdMob | Yandex Ads |
Select GoogleMobileAdsPlugin.unitypackage file. | and find the importedSelect yandex-mobileads-lite-2.9.0.unitypackage file. Import mobileads-admob-mediation-2.9.0.unitypackage from the mobileads-mediation directory. | and find the imported
AdMob | Yandex Ads |
Select GoogleMobileAdsPlugin.unitypackage file. | and find the importedSelect yandex-mobileads-lite-2.9.0.unitypackage file. Import mobileads-admob-mediation-2.9.0.unitypackage from the mobileads-mediation directory. | and find the imported
Before loading ads, initialize the library:
AdMob | Yandex Ads |
|
|
AdMob | Yandex Ads |
|
|
Ad formats
Interstitial
- Creating ad objects
-
AdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private InterstitialAd interstitial; private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/1033173712"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/4411468910"; #else string adUnitId = "unexpected_platform"; #endif this.interstitial = new InterstitialAd(adUnitId); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private Interstitial interstitial; private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "demo-interstitial-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-interstitial-yandex"; #else string adUnitId = "unexpected_platform"; #endif this.interstitial = new Interstitial(adUnitId); }
Copied to clipboardAdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private InterstitialAd interstitial; private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/1033173712"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/4411468910"; #else string adUnitId = "unexpected_platform"; #endif this.interstitial = new InterstitialAd(adUnitId); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private Interstitial interstitial; private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "demo-interstitial-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-interstitial-yandex"; #else string adUnitId = "unexpected_platform"; #endif this.interstitial = new Interstitial(adUnitId); }
Copied to clipboard - Loading ads
-
AdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. this.interstitial.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. this.interstitial.LoadAd(request);
Copied to clipboardAdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. this.interstitial.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. this.interstitial.LoadAd(request);
Copied to clipboard - Displaying ads
-
AdMob Yandex Ads private void ShowInterstitial() { if (this.interstitial.IsLoaded()) { this.interstitial.Show(); } else { Debug.Log("Interstitial is not ready yet"); } }
Copied to clipboardprivate void ShowInterstitial() { if (this.interstitial.IsLoaded()) { interstitial.Show(); } else { Debug.Log("Interstitial is not ready yet"); } }
Copied to clipboardAdMob Yandex Ads private void ShowInterstitial() { if (this.interstitial.IsLoaded()) { this.interstitial.Show(); } else { Debug.Log("Interstitial is not ready yet"); } }
Copied to clipboardprivate void ShowInterstitial() { if (this.interstitial.IsLoaded()) { interstitial.Show(); } else { Debug.Log("Interstitial is not ready yet"); } }
Copied to clipboard - Clearing ads
-
AdMob Yandex Ads interstitial.Destroy();
Copied to clipboardinterstitial.Destroy();
Copied to clipboardAdMob Yandex Ads interstitial.Destroy();
Copied to clipboardinterstitial.Destroy();
Copied to clipboard - Setting ad callbacks
-
AdMob Yandex Ads ... private void RequestInterstitial() { ... // Called when an ad request has successfully loaded. this.interstitial.OnAdLoaded += HandleOnAdLoaded; // Called when an ad request failed to load. this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad; // Called when an ad is shown. this.interstitial.OnAdOpening += HandleOnAdOpening; // Called when the ad is closed. this.interstitial.OnAdClosed += HandleOnAdClosed; ... } public void HandleOnAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleAdLoaded event received"); } public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message); } public void HandleOnAdOpening(object sender, EventArgs args) { MonoBehaviour.print("HandleAdOpening event received"); } public void HandleOnAdClosed(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClosed event received"); }
Copied to clipboard... private void RequestInterstitial() { ... // Called when an ad request has successfully loaded. this.interstitial.OnInterstitialLoaded += this.HandleInterstitialLoaded; // Called when an ad request failed to load. this.interstitial.OnInterstitialFailedToLoad += this.HandleInterstitialFailedToLoad; // Called when user returned to application after click. this.interstitial.OnReturnedToApplication += this.HandleReturnedToApplication; // Called when user is about to leave application after tapping on an ad. this.interstitial.OnLeftApplication += this.HandleLeftApplication; // Called when user clicked on the ad. this.interstitial.OnAdClicked += this.HandleAdClicked; // Called when an ad is shown. this.interstitial.OnInterstitialShown += this.HandleInterstitialShown; // Called when the ad is closed. this.interstitial.OnInterstitialDismissed += this.HandleInterstitialDismissed; // Called when an impression was tracked this.interstitial.OnImpression += this.HandleImpression; // Called when an ad request failed to show. this.interstitial.OnInterstitialFailedToShow += this.HandleInterstitialFailedToShow; ... } public void HandleInterstitialLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialLoaded event received"); } public void HandleInterstitialFailedToLoad(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleInterstitialFailedToLoad event received with message: " + args.Message); } public void HandleReturnedToApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleReturnedToApplication event received"); } public void HandleLeftApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleLeftApplication event received"); } public void HandleAdClicked(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClicked event received"); } public void HandleInterstitialShown(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialShown event received"); } public void HandleInterstitialDismissed(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialDismissed event received"); } public void HandleImpression(object sender, ImpressionData impressionData) { var data = impressionData == null ? "null" : impressionData.rawData; MonoBehaviour.print("HandleImpression event received with data: " + data); } public void HandleInterstitialFailedToShow(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleInterstitialFailedToShow event received with message: " + args.Message); }
Copied to clipboardAdMob Yandex Ads ... private void RequestInterstitial() { ... // Called when an ad request has successfully loaded. this.interstitial.OnAdLoaded += HandleOnAdLoaded; // Called when an ad request failed to load. this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad; // Called when an ad is shown. this.interstitial.OnAdOpening += HandleOnAdOpening; // Called when the ad is closed. this.interstitial.OnAdClosed += HandleOnAdClosed; ... } public void HandleOnAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleAdLoaded event received"); } public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message); } public void HandleOnAdOpening(object sender, EventArgs args) { MonoBehaviour.print("HandleAdOpening event received"); } public void HandleOnAdClosed(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClosed event received"); }
Copied to clipboard... private void RequestInterstitial() { ... // Called when an ad request has successfully loaded. this.interstitial.OnInterstitialLoaded += this.HandleInterstitialLoaded; // Called when an ad request failed to load. this.interstitial.OnInterstitialFailedToLoad += this.HandleInterstitialFailedToLoad; // Called when user returned to application after click. this.interstitial.OnReturnedToApplication += this.HandleReturnedToApplication; // Called when user is about to leave application after tapping on an ad. this.interstitial.OnLeftApplication += this.HandleLeftApplication; // Called when user clicked on the ad. this.interstitial.OnAdClicked += this.HandleAdClicked; // Called when an ad is shown. this.interstitial.OnInterstitialShown += this.HandleInterstitialShown; // Called when the ad is closed. this.interstitial.OnInterstitialDismissed += this.HandleInterstitialDismissed; // Called when an impression was tracked this.interstitial.OnImpression += this.HandleImpression; // Called when an ad request failed to show. this.interstitial.OnInterstitialFailedToShow += this.HandleInterstitialFailedToShow; ... } public void HandleInterstitialLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialLoaded event received"); } public void HandleInterstitialFailedToLoad(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleInterstitialFailedToLoad event received with message: " + args.Message); } public void HandleReturnedToApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleReturnedToApplication event received"); } public void HandleLeftApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleLeftApplication event received"); } public void HandleAdClicked(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClicked event received"); } public void HandleInterstitialShown(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialShown event received"); } public void HandleInterstitialDismissed(object sender, EventArgs args) { MonoBehaviour.print("HandleInterstitialDismissed event received"); } public void HandleImpression(object sender, ImpressionData impressionData) { var data = impressionData == null ? "null" : impressionData.rawData; MonoBehaviour.print("HandleImpression event received with data: " + data); } public void HandleInterstitialFailedToShow(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleInterstitialFailedToShow event received with message: " + args.Message); }
Copied to clipboard
Rewarded
- Creating ad objects
-
AdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private RewardedAd rewardedAd; private void RequestRewarded() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/5224354917"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/1712485313"; #else string adUnitId = "unexpected_platform"; #endif this.rewardedAd = new RewardedAd(adUnitId); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private RewardedAd rewardedAd; private void RequestRewarded() { #if UNITY_ANDROID string adUnitId = "demo-rewarded-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-rewarded-yandex"; #else string adUnitId = "unexpected_platform"; #endif this.rewardedAd = new RewardedAd(adUnitId); }
Copied to clipboardAdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private RewardedAd rewardedAd; private void RequestRewarded() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/5224354917"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/1712485313"; #else string adUnitId = "unexpected_platform"; #endif this.rewardedAd = new RewardedAd(adUnitId); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private RewardedAd rewardedAd; private void RequestRewarded() { #if UNITY_ANDROID string adUnitId = "demo-rewarded-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-rewarded-yandex"; #else string adUnitId = "unexpected_platform"; #endif this.rewardedAd = new RewardedAd(adUnitId); }
Copied to clipboard - Loading ads
-
AdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the rewarded ad with the request. this.rewardedAd.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the rewarded with the request. this.rewardedAd.LoadAd(request);
Copied to clipboardAdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the rewarded ad with the request. this.rewardedAd.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the rewarded with the request. this.rewardedAd.LoadAd(request);
Copied to clipboard - Displaying ads
-
AdMob Yandex Ads private void ShowRewardedAd() { if (this.rewardedAd.IsLoaded()) { this.rewardedAd.Show(); } else { Debug.Log("Rewarded ad is not ready yet"); } }
Copied to clipboardprivate void ShowRewardedAd() { if (this.rewardedAd.IsLoaded()) { rewardedAd.Show(); } else { Debug.Log("Rewarded Ad is not ready yet"); } }
Copied to clipboardAdMob Yandex Ads private void ShowRewardedAd() { if (this.rewardedAd.IsLoaded()) { this.rewardedAd.Show(); } else { Debug.Log("Rewarded ad is not ready yet"); } }
Copied to clipboardprivate void ShowRewardedAd() { if (this.rewardedAd.IsLoaded()) { rewardedAd.Show(); } else { Debug.Log("Rewarded Ad is not ready yet"); } }
Copied to clipboard - Clearing ads
-
AdMob Yandex Ads rewardedAd.Destroy();
Copied to clipboardrewardedAd.Destroy();
Copied to clipboardAdMob Yandex Ads rewardedAd.Destroy();
Copied to clipboardrewardedAd.Destroy();
Copied to clipboard - Setting ad callbacks
-
AdMob Yandex Ads ... private void RequestRewarded() { ... // Called when an ad request has successfully loaded. this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad; // Called when an ad is shown. this.rewardedAd.OnAdOpening += HandleRewardedAdOpening; // Called when an ad request failed to show. this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward; // Called when the ad is closed. this.rewardedAd.OnAdClosed += HandleRewardedAdClosed; ... } public void HandleRewardedAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdLoaded event received"); } public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToLoad event received with message: " + args.Message); } public void HandleRewardedAdOpening(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdOpening event received"); } public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToShow event received with message: " + args.Message); } public void HandleRewardedAdClosed(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdClosed event received"); } public void HandleUserEarnedReward(object sender, Reward args) { string type = args.Type; double amount = args.Amount; MonoBehaviour.print( "HandleRewardedAdRewarded event received for " + amount.ToString() + " " + type); }
Copied to clipboard... private void RequestRewarded() { ... // Called when an ad request has successfully loaded. this.rewardedAd.OnRewardedAdLoaded += this.HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnRewardedAdFailedToLoad += this.HandleRewardedAdFailedToLoad; // Called when user returned to application after click. this.rewardedAd.OnReturnedToApplication += this.HandleReturnedToApplication; // Called when user is about to leave application after tapping on an ad. this.rewardedAd.OnLeftApplication += this.HandleLeftApplication; // Called when user clicked on the ad. this.rewardedAd.OnAdClicked += this.HandleAdClicked; // Called when an ad is shown. this.rewardedAd.OnRewardedAdShown += this.HandleRewardedAdShown; // Called when the ad is closed. this.rewardedAd.OnRewardedAdDismissed += this.HandleRewardedAdDismissed; // Called when an impression was tracked this.rewardedAd.OnImpression += this.HandleImpression; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnRewarded += this.HandleRewarded; // Called when an ad request failed to show. this.rewardedAd.OnRewardedAdFailedToShow += this.HandleRewardedAdFailedToShow; ... } public void HandleRewardedAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdLoaded event received"); } public void HandleRewardedAdFailedToLoad(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToLoad event received with message: " + args.Message); } public void HandleReturnedToApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleReturnedToApplication event received"); } public void HandleLeftApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleLeftApplication event received"); } public void HandleAdClicked(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClicked event received"); } public void HandleRewardedAdShown(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdShown event received"); } public void HandleRewardedAdDismissed(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdDismissed event received"); } public void HandleImpression(object sender, ImpressionData impressionData) { var data = impressionData == null ? "null" : impressionData.rawData; MonoBehaviour.print("HandleImpression event received with data: " + data); } public void HandleRewarded(object sender, Reward args) { MonoBehaviour.print("HandleRewarded event received: amout = " + args.amount + ", type = " + args.type); } public void HandleRewardedAdFailedToShow(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToShow event received with message: " + args.Message); }
Copied to clipboardAdMob Yandex Ads ... private void RequestRewarded() { ... // Called when an ad request has successfully loaded. this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad; // Called when an ad is shown. this.rewardedAd.OnAdOpening += HandleRewardedAdOpening; // Called when an ad request failed to show. this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward; // Called when the ad is closed. this.rewardedAd.OnAdClosed += HandleRewardedAdClosed; ... } public void HandleRewardedAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdLoaded event received"); } public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToLoad event received with message: " + args.Message); } public void HandleRewardedAdOpening(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdOpening event received"); } public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToShow event received with message: " + args.Message); } public void HandleRewardedAdClosed(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdClosed event received"); } public void HandleUserEarnedReward(object sender, Reward args) { string type = args.Type; double amount = args.Amount; MonoBehaviour.print( "HandleRewardedAdRewarded event received for " + amount.ToString() + " " + type); }
Copied to clipboard... private void RequestRewarded() { ... // Called when an ad request has successfully loaded. this.rewardedAd.OnRewardedAdLoaded += this.HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnRewardedAdFailedToLoad += this.HandleRewardedAdFailedToLoad; // Called when user returned to application after click. this.rewardedAd.OnReturnedToApplication += this.HandleReturnedToApplication; // Called when user is about to leave application after tapping on an ad. this.rewardedAd.OnLeftApplication += this.HandleLeftApplication; // Called when user clicked on the ad. this.rewardedAd.OnAdClicked += this.HandleAdClicked; // Called when an ad is shown. this.rewardedAd.OnRewardedAdShown += this.HandleRewardedAdShown; // Called when the ad is closed. this.rewardedAd.OnRewardedAdDismissed += this.HandleRewardedAdDismissed; // Called when an impression was tracked this.rewardedAd.OnImpression += this.HandleImpression; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnRewarded += this.HandleRewarded; // Called when an ad request failed to show. this.rewardedAd.OnRewardedAdFailedToShow += this.HandleRewardedAdFailedToShow; ... } public void HandleRewardedAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdLoaded event received"); } public void HandleRewardedAdFailedToLoad(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToLoad event received with message: " + args.Message); } public void HandleReturnedToApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleReturnedToApplication event received"); } public void HandleLeftApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleLeftApplication event received"); } public void HandleAdClicked(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClicked event received"); } public void HandleRewardedAdShown(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdShown event received"); } public void HandleRewardedAdDismissed(object sender, EventArgs args) { MonoBehaviour.print("HandleRewardedAdDismissed event received"); } public void HandleImpression(object sender, ImpressionData impressionData) { var data = impressionData == null ? "null" : impressionData.rawData; MonoBehaviour.print("HandleImpression event received with data: " + data); } public void HandleRewarded(object sender, Reward args) { MonoBehaviour.print("HandleRewarded event received: amout = " + args.amount + ", type = " + args.type); } public void HandleRewardedAdFailedToShow(object sender, AdFailureEventArgs args) { MonoBehaviour.print( "HandleRewardedAdFailedToShow event received with message: " + args.Message); }
Copied to clipboard
Banner
- Creating ad objects
-
AdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private BannerView bannerView; private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/6300978111"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/2934735716"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private Banner bannerView; private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "demo-banner-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-banner-yandex"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. this.bannerView = new Banner(adUnitId, AdSize.BANNER_320x50, AdPosition.TopCenter); }
Copied to clipboardAdMob Yandex Ads using GoogleMobileAds.Api; using GoogleMobileAds.Common; ... private BannerView bannerView; private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/6300978111"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/2934735716"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top); }
Copied to clipboardusing YandexMobileAds; using YandexMobileAds.Base; ... private Banner bannerView; private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "demo-banner-yandex"; #elif UNITY_IPHONE string adUnitId = "demo-banner-yandex"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. this.bannerView = new Banner(adUnitId, AdSize.BANNER_320x50, AdPosition.TopCenter); }
Copied to clipboard - Setting the banner size
-
In addition to constants, the plugin lets you set an arbitrary banner size:
AdMob Yandex Ads AdSize adSize = new AdSize(250, 250); BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.Bottom);
Copied to clipboardAdSize adSize = AdSize.FlexibleSize(250, 250) BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.BottomCenter);
Copied to clipboardAdMob Yandex Ads AdSize adSize = new AdSize(250, 250); BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.Bottom);
Copied to clipboardAdSize adSize = AdSize.FlexibleSize(250, 250) BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.BottomCenter);
Copied to clipboard - Setting the position on the screen
-
AdMob Yandex Ads // Bottom center on the screen BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.Bottom); // custom coordinate BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, 0, 50);
Copied to clipboard// Bottom center on the screen BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.BottomCenter); // custom coordinate not possible in Yandex Ads
Copied to clipboardAdMob Yandex Ads // Bottom center on the screen BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.Bottom); // custom coordinate BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, 0, 50);
Copied to clipboard// Bottom center on the screen BannerView bannerView = new BannerView(adUnitId, adSize, AdPosition.BottomCenter); // custom coordinate not possible in Yandex Ads
Copied to clipboard - Loading ads
-
AdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. this.bannerView.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. this.bannerView.LoadAd(request);
Copied to clipboardAdMob Yandex Ads // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. this.bannerView.LoadAd(request);
Copied to clipboard// Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. this.bannerView.LoadAd(request);
Copied to clipboard - Clearing ads
-
AdMob Yandex Ads bannerView.Destroy();
Copied to clipboardbannerView.Destroy();
Copied to clipboardAdMob Yandex Ads bannerView.Destroy();
Copied to clipboardbannerView.Destroy();
Copied to clipboard