/// <summary> /// Displays a rewarded ad. /// /// If the display was successful, the event `RewardedDisplayedEvent` will be called when the ad closes. /// Otherwise, the event `RewardedNotDisplayedEvent` will be called. /// </summary> /// <param name="tag">The game tag from where the ad will be displayed (like menu or store).</param> public void ShowRewarded(string tag) { RunIfInitialized(() => { AdsLogger.LogWithFormat("{0} | Show rewarded at tag {1}", _label, tag); _adsBinding.ShowRewarded(tag); }); }
/// <summary> /// Displays a banner ad. /// /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called. /// Otherwise, the event `BannerFailedDisplayedEvent` will be called. /// </summary> /// <param name="tag">The game tag from where the ad will be displayed (like menu or store).</param> /// <param name="bannerSize">The bannerSize of the Ad.</param> /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param> public void ShowBanner(string tag, BannerSize bannerSize, BannerPosition bannerPosition) { RunIfInitialized(() => { AdsLogger.LogWithFormat("{0} | Show banner at tag {1}", _label, tag); _adsBinding.ShowBanner(tag, bannerSize, bannerPosition); }); }
/// <summary> /// Displays an interstitial ad. /// /// If the display was successful, the event `InterstitialDisplayedEvent` will be called when the ad closes. /// Otherwise, the event `InterstitialNotDisplayedEvent` will be called. /// </summary> /// <param name="tag">The game tag from where the ad will be displayed (like menu or store).</param> public void ShowInterstitial(string tag) { RunIfInitialized(() => { AdsLogger.LogWithFormat("{0} | Show interstitial at tag {1}", _label, tag); _adsBinding.ShowInterstitial(tag); }); }
/// <summary> /// Stops a banner ad. /// /// </summary> /// <param name="tag">The game tag from where the ad will be removed from (like menu or store).</param> public void StopBanner(string tag) { RunIfInitialized(() => { AdsLogger.LogWithFormat("{0} | Stop banner at tag {1}", _label, tag); _adsBinding.StopBanner(tag); }); }
private static void RunIfInitialized(Action action) { if (!_isInitialized) { AdsLogger.LogError("ScaleMonk SDK must be initialized. Make sure to call ScaleMonkAds.Initialize()"); return; } action(); }
/// <summary> /// Initialize ScaleMonk SDK /// /// <param name="callback">The callback that will be called after the ScaleMonk SDK is initialized</param> /// </summary> public static void Initialize(Action callback) { if (_isInitialized) { AdsLogger.LogWarning("{0} | Ads SDK already initialized", _label); return; } AdsLogger.LogWithFormat("{0} | Initializing Ads SDK", _label); _instance = SharedInstance; _isInitialized = true; _initializationCallback = callback; ScaleMonkAdsMonoBehavior.Initialize(_instance); _instance.InitializeInternal(); }
public void CompletedBannerDisplay(string tag) { AdsLogger.LogWithFormat("{0} | Banner displayed at tag {1}", _label, tag); CallAction(BannerCompletedDisplayedEvent); }
public void RewardedNotReady() { AdsLogger.LogWithFormat("{0} | Rewarded ad not ready to be displayed", _label); CallAction(RewardedNotReadyEvent); }
public void InitializationCompleted() { AdsLogger.LogWithFormat("{0} | Completed initialization", _label); _adsInstance.InitializationCompleted(); }
public void FailedInterstitialDisplay(string tag) { AdsLogger.LogWithFormat("{0} | Interstitial not displayed at tag {1}", _label, tag); CallAction(InterstitialNotDisplayedEvent); }
public void InterstitialNotReady() { AdsLogger.LogWithFormat("{0} | Interstitial not ready to be displayed", _label); CallAction(InterstitialNotReadyEvent); }
public void InterstitialNotReady() { AdsLogger.LogWithFormat("{0} | Interstitial not ready to display", _label); _adsInstance.InterstitialNotReady(); }
public void ClickedInterstitial(string tag) { AdsLogger.LogWithFormat("{0} | Clicked interstitial at tag {1}", _label, tag); CallAction(InterstitialClickedEvent); }
public void StartedRewardedDisplay(string tag) { AdsLogger.LogWithFormat("{0} | Started rewarded at tag {1}", _label, tag); CallAction(RewardedStartedEvent); }
public void ClickedRewarded(string tag) { AdsLogger.LogWithFormat("{0} | Clicked rewarded at tag {1}", _label, tag); CallAction(RewardedClickedEvent); }
public void ClickedRewarded(string location) { AdsLogger.LogWithFormat("{0} | Clicked video at location \"{1}\"", _label, location); _adsInstance.ClickedRewarded(location); }
public void CompletedBannerDisplay(string location) { AdsLogger.LogWithFormat("{0} | Completed banner display at location \"{1}\"", _label, location); _adsInstance.CompletedBannerDisplay(location); }
public void FailedRewardedDisplay(string location) { AdsLogger.LogWithFormat("{0} | Failed video display at location \"{1}\"", _label, location); _adsInstance.FailedRewardedDisplay(location); }
public void ClickedInterstitial(string location) { AdsLogger.LogWithFormat("{0} | Clicked interstitial at location \"{1}\"", _label, location); _adsInstance.ClickedInterstitial(location); }
public static EditorPosition toEditorPosition(this BannerPosition position) { Vector2 anchorMin; Vector2 anchorMax; Vector2 pivot; switch (position) { case BannerPosition.TopCenter: anchorMin = new Vector2(0.5f, 1); anchorMax = new Vector2(0.5f, 1); pivot = new Vector2(0.5f, 1); break; case BannerPosition.TopLeft: anchorMin = new Vector2(0, 1); anchorMax = new Vector2(0, 1); pivot = new Vector2(0, 1); break; case BannerPosition.TopRight: anchorMin = new Vector2(1, 1); anchorMax = new Vector2(1, 1); pivot = new Vector2(1, 1); break; case BannerPosition.Centered: anchorMin = new Vector2(0.5f, 0.5f); anchorMax = new Vector2(0.5f, 0.5f); pivot = new Vector2(0.5f, 0.5f); break; case BannerPosition.CenterLeft: anchorMin = new Vector2(0, 0.5f); anchorMax = new Vector2(0, 0.5f); pivot = new Vector2(0, 0.5f); break; case BannerPosition.CenterRight: anchorMin = new Vector2(1, 0.5f); anchorMax = new Vector2(1, 0.5f); pivot = new Vector2(1, 0.5f); break; case BannerPosition.BottomLeft: anchorMin = new Vector2(0, 0); anchorMax = new Vector2(0, 0); pivot = new Vector2(0, 0); break; case BannerPosition.BottomCenter: anchorMin = new Vector2(0.5f, 0); anchorMax = new Vector2(0.5f, 0); pivot = new Vector2(0.5f, 0); break; case BannerPosition.BottomRight: anchorMin = new Vector2(1, 0); anchorMax = new Vector2(1, 0); pivot = new Vector2(1, 0); break; default: AdsLogger.LogError("Position is not valid"); throw new Exception("Position is not valid"); } return(new EditorPosition(anchorMin, anchorMax, pivot)); }
public void InitializationCompleted() { AdsLogger.LogWithFormat("{0} | SDK Initialization Completed", _label); CallAction(_initializationCallback); }
public void FailedRewardedDisplay(string tag) { AdsLogger.LogWithFormat("{0} | Rewarded not displayed at tag {1}", _label, tag); CallAction(RewardedNotDisplayedEvent); }
public void RewardedNotReady() { AdsLogger.LogWithFormat("{0} | Rewarded not ready to display", _label); _adsInstance.RewardedNotReady(); }
public void FailedInterstitialDisplay(string location) { AdsLogger.LogWithFormat("{0} | Failed interstitial display at location \"{1}\"", _label, location); _adsInstance.FailedInterstitialDisplay(location); }