//------------------------------------------------------------ // 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 }
/** * Loads and displays the AppLovin banner ad at given position * * @param {float} x Horizontal position of the ad (AD_POSITION_LEFT, AD_POSITION_CENTER, AD_POSITION_RIGHT) or float * @param {float} y Vertical position of the ad (AD_POSITION_TOP, AD_POSITION_BOTTOM) or float */ public static void ShowAd(float x, float y) { AppLovin.SetAdPosition(x, y); AppLovin.ShowAd(); }