private AdSize ToAdMobAdSize(BannerAdSize adSize) { return(adSize.IsSmartBanner ? AdSize.SmartBanner : new AdSize(adSize.Width, adSize.Height)); }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { Debug.LogWarning(BANNER_UNSUPPORTED_MESSAGE); }
//------------------------------------------------------------ // 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 }
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 }
protected IronSourceBannerSize ToIronSourceBannerSize(BannerAdSize adSize) { return(adSize.IsSmartBanner ? IronSourceBannerSize.SMART : ToIronSourceNearestSize(adSize)); }
protected override void InternalShowBannerAd(AdPlacement _, BannerAdPosition __, BannerAdSize ___) { Debug.Log(BANNER_UNSUPPORTED_MESSAGE); }
//------------------------------------------------------------ // 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 virtual AdSize ToFBAdSize(BannerAdSize adSize) { return(adSize.IsSmartBanner ? AdSize.BANNER_HEIGHT_50 : ToFBNearestSize(adSize)); }
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 }
/// <summary> /// Instructs the underlaying SDK to show a banner ad. Only invoked if the client is initialized. /// </summary> /// <param name="placement">Placement.</param> /// <param name="position">Position.</param> /// <param name="size">Size.</param> protected abstract void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size);
protected virtual BannerAd ShowBannerAd(BannerAd banner, string bannerID, BannerAdPosition position, BannerAdSize size, AdPlacement placement) { /// If the default banner is null or user request a new banner with different size with the created one, /// create a new banner (since we can only set fb's banner ad size when creating it). if (banner == null || banner.Ad == null || banner.CurrentSize != ToFBAdSize(size)) { /// Destroy old banner. DestroyBannerAd(placement); /// Create new one. banner = CreateNewBannerAd(bannerID, ToFBAdSize(size)); } /// Load the banner if it hasn't been loaded yet. if (!banner.IsLoaded) { banner.Ad.LoadAd(); } banner.Ad.Show(ToFBAudienceAdPosition(position)); return(banner); }
/// <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); } }
/// <summary> /// Shows the banner ad at the default placement. /// </summary> /// <param name="position">Position.</param> /// <param name="size">Size.</param> public virtual void ShowBannerAd(BannerAdPosition position, BannerAdSize size) { ShowBannerAd(AdPlacement.Default, position, size); }
//------------------------------------------------------------ // 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_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 }
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 }