/// <summary> /// Shows the banner ad at the specified placement, position and size. /// </summary> /// <param name="placement">Placement.</param> /// <param name="position">Position.</param> /// <param name="size">Size.</param> public virtual void ShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { if (IsSdkAvail) { if (placement == null) { Debug.LogFormat("Cannot show {0} banner ad at placement: null", Network.ToString()); return; } if (size == null) { Debug.LogFormat("Cannot show {0} banner ad with ad size: null", Network.ToString()); return; } if (CheckInitialize()) { InternalShowBannerAd(placement, position, size); } } else { Debug.Log(NoSdkMessage); } }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_FBAN string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerId.Id : FindIdForPlacement(mAdSettings.CustomBannerIds, placement); if (string.IsNullOrEmpty(id)) { Debug.LogFormat("Attempting to show {0} banner ad with an undefined ID at placement {1}", Network.ToString(), AdPlacement.GetPrintableName(placement)); return; } if (placement.Equals(AdPlacement.Default)) // Default banner... { mDefaultBanner = ShowBannerAd(mDefaultBanner, id, position, size, placement); } else // Custom banner... { if (!mCustomBannerAds.ContainsKey(placement)) { mCustomBannerAds.Add(placement, CreateNewBannerAd(id, ToFBAdSize(size))); } mCustomBannerAds[placement] = ShowBannerAd(mCustomBannerAds[placement], id, position, size, placement); } #endif }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_ADCOLONY AdColonyAdView adview = null; if (placement == AdPlacement.Default) { adview = mDefaultBannerAd; showDefaultBannerAd = true; } else { mCustomBannerAds.TryGetValue(placement, out adview); showCustomBannerAds[placement] = true; } if (adview != null) { adview.ShowAdView(); } else { LoadBannerAd(placement, position, size); } #endif }
private AdPosition ToAdMobAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Top: return(AdPosition.Top); case BannerAdPosition.Bottom: return(AdPosition.Bottom); case BannerAdPosition.TopLeft: return(AdPosition.TopLeft); case BannerAdPosition.TopRight: return(AdPosition.TopRight); case BannerAdPosition.BottomLeft: return(AdPosition.BottomLeft); case BannerAdPosition.BottomRight: return(AdPosition.BottomRight); default: return(AdPosition.Top); } }
private MaxSdk.BannerPosition ToAppLovinAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Top: return(MaxSdk.BannerPosition.TopCenter); case BannerAdPosition.Bottom: return(MaxSdk.BannerPosition.BottomCenter); case BannerAdPosition.TopLeft: return(MaxSdk.BannerPosition.TopLeft); case BannerAdPosition.TopRight: return(MaxSdk.BannerPosition.TopRight); case BannerAdPosition.BottomLeft: return(MaxSdk.BannerPosition.BottomLeft); case BannerAdPosition.BottomRight: return(MaxSdk.BannerPosition.BottomRight); default: return(MaxSdk.BannerPosition.Centered); } }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ public void ShowBannerAd(BannerAdPosition position, BannerAdSize size) { #if EM_ADMOB // If no bannerView object exists, create a new one and load ad into it. // Otherwise just show the existing banner (which may be hidden before). if (bannerView == null) { bannerView = new BannerView( globalAdSettings.AdMobIds.BannerAdId, size.ToAdMobAdSize(), position.ToAdMobAdPosition() ); // Register for banner ad events. bannerView.OnAdLoaded += HandleAdMobBannerAdLoaded; bannerView.OnAdFailedToLoad += HandleAdMobBannerAdFailedToLoad; bannerView.OnAdOpening += HandleAdMobBannerAdOpened; bannerView.OnAdClosed += HandleAdMobBannerAdClosed; bannerView.OnAdLeavingApplication += HandleAdMobBannerAdLeftApplication; // Load ad. bannerView.LoadAd(CreateAdMobAdRequest()); } bannerView.Show(); #else Debug.LogError(NO_SDK_MESSAGE); #endif }
private BannerPosition ToUnityAdsBannerPosition(BannerAdPosition position) { switch (position) { case BannerAdPosition.Bottom: return(BannerPosition.BOTTOM_CENTER); case BannerAdPosition.BottomLeft: return(BannerPosition.BOTTOM_LEFT); case BannerAdPosition.BottomRight: return(BannerPosition.BOTTOM_RIGHT); case BannerAdPosition.Top: return(BannerPosition.TOP_CENTER); case BannerAdPosition.TopLeft: return(BannerPosition.TOP_LEFT); case BannerAdPosition.TopRight: return(BannerPosition.TOP_RIGHT); default: return(BannerPosition.CENTER); } }
private AppLovinAdPosition ToAppLovinAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Top: return(new AppLovinAdPosition(AppLovin.AD_POSITION_CENTER, AppLovin.AD_POSITION_TOP)); case BannerAdPosition.Bottom: return(new AppLovinAdPosition(AppLovin.AD_POSITION_CENTER, AppLovin.AD_POSITION_BOTTOM)); case BannerAdPosition.TopLeft: return(new AppLovinAdPosition(AppLovin.AD_POSITION_LEFT, AppLovin.AD_POSITION_TOP)); case BannerAdPosition.TopRight: return(new AppLovinAdPosition(AppLovin.AD_POSITION_RIGHT, AppLovin.AD_POSITION_TOP)); case BannerAdPosition.BottomLeft: return(new AppLovinAdPosition(AppLovin.AD_POSITION_LEFT, AppLovin.AD_POSITION_BOTTOM)); case BannerAdPosition.BottomRight: return(new AppLovinAdPosition(AppLovin.AD_POSITION_RIGHT, AppLovin.AD_POSITION_BOTTOM)); default: return(new AppLovinAdPosition(AppLovin.AD_POSITION_CENTER, AppLovin.AD_POSITION_TOP)); } }
public static AdPosition ToAdMobAdPosition(this BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Top: return(AdPosition.Top); case BannerAdPosition.Bottom: return(AdPosition.Bottom); case BannerAdPosition.TopLeft: return(AdPosition.TopLeft); case BannerAdPosition.TopRight: return(AdPosition.TopRight); case BannerAdPosition.BottomLeft: return(AdPosition.BottomLeft); case BannerAdPosition.BottomRight: return(AdPosition.BottomRight); default: return(AdPosition.Top); } }
protected MoPubBase.AdPosition ToMoPubAdPosition(BannerAdPosition adPosition) { switch (adPosition) { case BannerAdPosition.Top: return(MoPubBase.AdPosition.TopCenter); case BannerAdPosition.Bottom: return(MoPubBase.AdPosition.BottomCenter); case BannerAdPosition.TopLeft: return(MoPubBase.AdPosition.TopLeft); case BannerAdPosition.TopRight: return(MoPubBase.AdPosition.TopRight); case BannerAdPosition.BottomLeft: return(MoPubBase.AdPosition.BottomLeft); case BannerAdPosition.BottomRight: return(MoPubBase.AdPosition.BottomRight); default: return(MoPubBase.AdPosition.Centered); } }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize __) { #if EM_FAIRBID string id = placement == AdPlacement.Default ? mGlobalAdSettings.DefaultBannerId : ToFairBidAdTag(placement); BannerOptions showOptions = new BannerOptions(); switch (position) { case BannerAdPosition.TopLeft: case BannerAdPosition.TopRight: case BannerAdPosition.Top: showOptions.DisplayAtTheTop(); break; case BannerAdPosition.BottomLeft: case BannerAdPosition.BottomRight: case BannerAdPosition.Bottom: showOptions.DisplayAtTheBottom(); break; default: showOptions.DisplayAtTheBottom(); break; } Banner.Show(id, showOptions); #endif }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { VungleBannerAd ad = GetBannerVungleAd(placement); if (ad == null) { return; } ad.Show(size, position); }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ public void ShowBannerAd(BannerAdPosition position, BannerAdSize size) { #if EM_HEYZAP HZBannerShowOptions showOptions = new HZBannerShowOptions(); showOptions.Position = position.ToHeyzapAdPosition(); HZBannerAd.ShowWithOptions(showOptions); #else Debug.LogError(NO_SDK_MESSAGE); #endif }
private static void ShowBannerAd(IAdClient client, BannerAdPosition position, BannerAdSize size) { if (IsAdRemoved()) { Debug.Log("Could not show banner ad: ads were disabled by RemoveAds()."); return; } client.ShowBannerAd(position, size); }
private static void ShowBannerAd(IAdClient client, AdPlacement placement, BannerAdPosition position, BannerAdSize size) { if (IsAdRemoved()) { Debug.Log("Could not show banner ad: ads were removed."); return; } client.ShowBannerAd(placement, position, size); AddActiveBannerAd(client.Network, placement); }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_APPLOVIN string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (placement.Equals(AdPlacement.Default)) // Default banner... { /// Create a new banner if user request a /// banner ad with different position or size. if (position != mDefaultBannerPosition) { Debug.Log("Creating new default banner..."); mDefaultBannerPosition = position; } AppLovinAdPosition pos = ToAppLovinAdPosition(position); AppLovin.SetAdPosition(pos.x, pos.y); if (string.IsNullOrEmpty(id)) { AppLovin.ShowAd(); } else { AppLovin.ShowAd(id); } } else // Custom banner... { /// Create a new banner if the banner with this key hasn't been initialized or /// user request new banner with existed key but different position or size. bool shouldCreateFlag = !mCustomBanners.ContainsKey(placement) || mCustomBanners[placement].Key != position || mCustomBanners[placement].Value != size; if (shouldCreateFlag) { Debug.Log("Creating new custom banner..."); mCustomBanners[placement] = new KeyValuePair <BannerAdPosition, BannerAdSize>(position, size); } AppLovinAdPosition pos = ToAppLovinAdPosition(position); AppLovin.SetAdPosition(pos.x, pos.y); if (string.IsNullOrEmpty(id)) { AppLovin.ShowAd(); } else { AppLovin.ShowAd(id); } } #endif }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize __) { #if EM_HEYZAP HZBannerShowOptions showOptions = new HZBannerShowOptions { Position = ToHeyzapAdPosition(position), Tag = ToHeyzapAdTag(placement) }; HZBannerAd.ShowWithOptions(showOptions); #endif }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_MOPUB string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerId.Id : FindIdForPlacement(mAdSettings.CustomBannerIds, placement); if (string.IsNullOrEmpty(id)) { Debug.LogFormat("Attempting to show {0} banner ad with an undefined ID at placement {1}", Network.ToString(), AdPlacement.GetPrintableName(placement)); return; } if (placement.Equals(AdPlacement.Default)) // Default banner... { /// Create a new banner if user request a /// banner ad with different position or size. if (position != mDefaultBannerPosition || size != mDefaultBannerSize) { Debug.Log("Creating new default banner..."); mDefaultBannerPosition = position; mDefaultBannerSize = size; mIsDefaultBannerAdReady = false; } if (!mIsDefaultBannerAdReady) { CreateBannerAd(id, position, size); } MoPub.ShowBanner(id, true); } else // Custom banner... { /// Create a new banner if the banner with this key hasn't been initialized or /// user request new banner with existed key but different position or size. bool shouldCreateFlag = !mCustomBanners.ContainsKey(placement) || mCustomBanners[placement].Key != position || mCustomBanners[placement].Value != size; if (shouldCreateFlag) { Debug.Log("Creating new custom banner..."); /// Create new banner & save its position & size to compare later. CreateBannerAd(id, position, size); mCustomBanners[placement] = new KeyValuePair <BannerAdPosition, BannerAdSize>(position, size); } MoPub.ShowBanner(id, true); } #endif }
private void LoadBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_ADCOLONY string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); AdColony.AdPosition bannerPosition = AdPosition.Bottom; switch (position) { case BannerAdPosition.Top: bannerPosition = AdPosition.Top; break; case BannerAdPosition.Bottom: bannerPosition = AdPosition.Bottom; break; case BannerAdPosition.TopLeft: bannerPosition = AdPosition.TopLeft; break; case BannerAdPosition.TopRight: bannerPosition = AdPosition.TopRight; break; case BannerAdPosition.BottomLeft: bannerPosition = AdPosition.BottomLeft; break; case BannerAdPosition.BottomRight: bannerPosition = AdPosition.BottomRight; break; default: break; } var adOptions = new AdOptions() { ShowPrePopup = mAdSettings.EnableRewardedAdPrePopup, ShowPostPopup = mAdSettings.EnableRewardedAdPostPopup }; if (!string.IsNullOrEmpty(id)) { AdColony.Ads.RequestAdView(id, AdColony.AdSize.Banner, bannerPosition, adOptions); } else { Debug.Log("Attempting to load AdColony banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); } #endif }
internal void Show(BannerAdSize size, BannerAdPosition position) { #if EM_VUNGLE if (Vungle.isAdvertAvailable(Id.Id, GetVungleBannerSize(size))) { Vungle.showBanner(Id.Id); } else { Vungle.loadBanner(Id.Id, GetVungleBannerSize(size), GetVungleBannerPosition(position)); } #endif isShowing = true; }
protected IronSourceBannerPosition ToIronSourceBannerPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Top: case BannerAdPosition.TopLeft: case BannerAdPosition.TopRight: return(IronSourceBannerPosition.TOP); case BannerAdPosition.Bottom: case BannerAdPosition.BottomLeft: case BannerAdPosition.BottomRight: default: return(IronSourceBannerPosition.BOTTOM); } }
protected virtual AdPosition ToFBAudienceAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.Bottom: case BannerAdPosition.BottomLeft: case BannerAdPosition.BottomRight: return(AdPosition.BOTTOM); case BannerAdPosition.Top: case BannerAdPosition.TopLeft: case BannerAdPosition.TopRight: default: return(AdPosition.TOP); } }
protected void CreateBannerAd(string id, BannerAdPosition position, BannerAdSize size) { #if UNITY_ANDROID // MoPub doesn't allow setting banner type on Android, so we'll ignore 'size'. MoPub.CreateBanner(id, ToMoPubAdPosition(position)); #else if (size == BannerAdSize.SmartBanner) { MoPub.CreateBanner(id, ToMoPubAdPosition(position)); } else { MoPub.CreateBanner(id, ToMoPubAdPosition(position), ToNearestMoPubBannerType(size)); } #endif }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition postition, BannerAdSize size) { #if UNITY_MONETIZATION string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to show UnityAds banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } if (!Advertisement.Banner.isLoaded) { BannerLoadOptions options = new BannerLoadOptions(); options.errorCallback += ((string message) => { Debug.Log("Error: " + message); }); options.loadCallback += (() => { Debug.Log("Ad Loaded"); }); Debug.Log("Loading banner ad"); Advertisement.Banner.Load(id, options); } else { var showOptions = new BannerOptions { showCallback = () => { InternalShowBannerAdCallback(placement); } }; Advertisement.Banner.Show(id, showOptions); } #else Debug.LogWarning(BANNER_UNSUPPORTED_MESSAGE); #endif }
private string ToFairBidAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.TopLeft: case BannerAdPosition.TopRight: case BannerAdPosition.Top: return("top"); case BannerAdPosition.BottomLeft: case BannerAdPosition.BottomRight: case BannerAdPosition.Bottom: return("bottom"); default: return("bottom"); } }
private string ToHeyzapAdPosition(BannerAdPosition pos) { switch (pos) { case BannerAdPosition.TopLeft: case BannerAdPosition.TopRight: case BannerAdPosition.Top: return(HZBannerShowOptions.POSITION_TOP); case BannerAdPosition.BottomLeft: case BannerAdPosition.BottomRight: case BannerAdPosition.Bottom: return(HZBannerShowOptions.POSITION_BOTTOM); default: return(HZBannerShowOptions.POSITION_TOP); } }
/// <summary> /// Create new banner, register all the events and load it automatically. /// </summary> /// <param name="position">The new banner will be placed at this position.</param> /// <param name="size">Size of the new banner.</param> /// <param name="bannerId">Id to request new banner.</param> private BannerView CreateNewBanner(BannerAdPosition position, BannerAdSize size, string bannerId) { BannerView newBanner = new BannerView( bannerId, ToAdMobAdSize(size), ToAdMobAdPosition(position) ); /// Register for banner ad events. newBanner.OnAdLoaded += HandleAdMobBannerAdLoaded; newBanner.OnAdFailedToLoad += HandleAdMobBannerAdFailedToLoad; newBanner.OnAdOpening += HandleAdMobBannerAdOpening; newBanner.OnAdClosed += HandleAdMobBannerAdClosed; newBanner.OnAdLeavingApplication += HandleAdMobBannerAdLeftApplication; newBanner.LoadAd(CreateAdMobAdRequest()); return(newBanner); }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_IRONSOURCE // If player requests a banner with different position or size, // we have to load a new banner. var newPos = ToIronSourceBannerPosition(position); var newSize = ToIronSourceBannerSize(size); if (mCurrentBannerAdPlacement != placement) { mCurrentBannerAdPlacement = placement; mIsBannerAdLoaded = false; } if (mCurrentBannerAdPos != newPos) { mCurrentBannerAdPos = newPos; mIsBannerAdLoaded = false; } if (mCurrentBannerAdSize != newSize) { mCurrentBannerAdSize = newSize; mIsBannerAdLoaded = false; } if (!mIsBannerAdLoaded) { string placementName = ToIronSourcePlacementName(mCurrentBannerAdPlacement); if (string.IsNullOrEmpty(placementName)) { IronSource.Agent.loadBanner(mCurrentBannerAdSize, mCurrentBannerAdPos); } else { IronSource.Agent.loadBanner(mCurrentBannerAdSize, mCurrentBannerAdPos, placementName); } } IronSource.Agent.displayBanner(); #endif }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_ADMOB string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to show AdMob banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } // If the requested banner (default or custom) doesn't exist or player request a banner with different size, create a new one and show it. // Otherwise just show the existing banner (which might be hidden before). if (placement == AdPlacement.Default) // Default banner... { if (mDefaultBanner == null || mCurrentDefaultBannerSize != size) { mDefaultBanner = CreateNewBanner(position, size, id); mCurrentDefaultBannerSize = size; Debug.Log("Creating new default banner..."); } mDefaultBanner.SetPosition(ToAdMobAdPosition(position)); mDefaultBanner.Show(); } else // Custom banner... { if (!mCustomBannerAds.ContainsKey(placement) || mCustomBannerAds[placement].Value == null || mCustomBannerAds[placement].Key != size) { mCustomBannerAds[placement] = new KeyValuePair <BannerAdSize, BannerView>(size, CreateNewBanner(position, size, id)); Debug.Log("Creating new custom banner..."); } mCustomBannerAds[placement].Value.SetPosition(ToAdMobAdPosition(position)); mCustomBannerAds[placement].Value.Show(); } #endif }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_APPLOVIN string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (string.IsNullOrEmpty(id)) { return; } bool shouldCreateNewBanner = true; if (mCreatedBanners.ContainsKey(placement) && mCreatedBanners[placement].Key == position && mCreatedBanners[placement].Value == size) { shouldCreateNewBanner = false; } if (shouldCreateNewBanner) { DestroyBannerAd(placement); MaxSdk.CreateBanner(id, ToAppLovinAdPosition(position)); MaxSdk.SetBannerBackgroundColor(id, new Color(1, 1, 1, 0)); if (!mCreatedBanners.ContainsKey(placement)) { mCreatedBanners.Add(placement, new KeyValuePair <BannerAdPosition, BannerAdSize>(position, size)); } mCreatedBanners[placement] = new KeyValuePair <BannerAdPosition, BannerAdSize>(position, size); } MaxSdk.ShowBanner(id); #endif }