IEnumerator ShowWhenReady(string placementId, ShowAdFinishCallback cb) { while (!Monetization.IsReady(placementId)) { yield return(new WaitForSeconds(0.25f)); } ShowAdCallbacks options = new ShowAdCallbacks(); if (cb != null) { options.finishCallback = cb; } ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent; if (ad != null) { ad.Show(options); } }
private IEnumerator ShowAdWhenReady(ShowAdFinishCallback onFinish) { if (string.IsNullOrEmpty(myPlacementId)) { yield break; } while (!Advertisement.isInitialized) { yield return(new WaitForSeconds(0.1f)); } while (!Monetization.IsReady(myPlacementId)) { yield return(new WaitForSeconds(0.1f)); } ShowAdPlacementContent ad = null; ad = Monetization.GetPlacementContent(myPlacementId) as ShowAdPlacementContent; if (ad != null) { ad.Show(onFinish); } }
static extern void UnityMonetizationPlacementContentShowAd(IntPtr pPlacementContent, ShowAdStartCallback startCallback, ShowAdFinishCallback finishCallback);
public void ShowRewarded(ShowAdFinishCallback cb) { StartCoroutine(ShowWhenReady("rewardedVideo", cb)); }
public void ShowRegular(ShowAdFinishCallback cb = null) { StartCoroutine(ShowWhenReady("video", cb)); }
public void ShowAds(string placementId, ShowAdFinishCallback onFinish) { myPlacementId = placementId; StartCoroutine(ShowAdWhenReady(onFinish)); }