public void xButtonClicked() { xButtonWasClicked = true; if (AdGemPlugin.videoIsPlaying) //If video is still playing, go to the endcard { VideoEndReached(videoPlayer); if (AdGemPlugin.rewardMode) { AdGemManager.staticRef.fireEventEndpoint("videoskip", "rewarded-video", AdGemManager.rewardedVideoCacheId); if (AdGem.rewardVideoCanceled != null) { AdGem.rewardVideoCanceled(); } } else { AdGemManager.staticRef.fireEventEndpoint("videoskip", "nonrewarded-video", AdGemManager.interstitialVideoCacheId); if (AdGem.interstitialVideoCanceled != null) { AdGem.interstitialVideoCanceled(); } } } else //Otherwise, if we are on the endcard, close the ad { if (AdGemPlugin.carouselEndCardShowing) { for (int i = 0; i < carouselContainerRect.childCount; i++) { Destroy(carouselContainerRect.GetChild(i).gameObject); } carouselContainerRect.transform.DetachChildren(); } if (AdGemPlugin.rewardMode) { AdGemManager.staticRef.fireEventEndpoint("videocomplete", "rewarded-video", AdGemManager.rewardedVideoCacheId); } else { AdGemManager.staticRef.fireEventEndpoint("videocomplete", "nonrewarded-video", AdGemManager.interstitialVideoCacheId); } AdGemPlugin.videoIsPlaying = false; AdGemPlugin.customEndCardShowing = false; AdGemPlugin.fullScreenEndCardShowing = false; AdGemPlugin.carouselEndCardShowing = false; videoPlayer.Stop(); restoreCurrentScene(); videoAdProcessFullyCompleted(); } }
public void showOfferWall() { bool showOfferWallInBrowser = true; //Debug.Log(">>>>>>>>>>>> os version: " + GetMajorOsVersion(AdGemPlugin.getOsVersion())); int osMajorVersion = AdGem.GetMajorOsVersion(AdGemPlugin.getOsVersion()); #if UNITY_ANDROID if (osMajorVersion >= 5) { showOfferWallInBrowser = false; } #endif #if UNITY_IOS if (osMajorVersion >= 9) { showOfferWallInBrowser = false; } #endif if (AdGemPlugin.openOfferWallInBrowser) { showOfferWallInBrowser = true; } if (showOfferWallInBrowser) { if (AdGem.verboseLogging) { Debug.Log("Adgem - showing offer wall in browser"); } Application.OpenURL(AdGemPlugin.getOfferWallUrl(false)); AdGemManager.staticRef.startPollingProcess(); if (AdGem.offerWallClosed != null) { StartCoroutine(waitThenCallOfferWallClosed()); } } else { if (goWebview != null) { adGemWebview.showOfferWall(); } else { Debug.Log("Adgem --- Error! Offer wall not initialized."); } } }
void Start() { //Dynamic config example IronSourceConfig.Instance.setClientSideCallbacks(true); string id = IronSource.Agent.getAdvertiserId(); //IronSource.Agent.validateIntegration(); // SDK init IronSource.Agent.init(IS_APP_KEY); IronSource.Agent.loadInterstitial(); AdGem.loadOfferWallBeforeShowing = true; AdGem.startSession(AdGem_APP_ID, false, false, true); }
public bool ShowOfferwallAd(Offerwall_Co _Co) { #if UNITY_EDITOR Debug.Log("Show " + _Co + " Offerwall"); return(CheckOfferwallAvailable(_Co)); #endif switch (_Co) { case Offerwall_Co.IS: if (IronSource.Agent.isOfferwallAvailable()) { IronSource.Agent.showOfferwall(); return(true); } break; case Offerwall_Co.AdGem: if (AdGem.offerWallReady) { AdGem.showOfferWall(); return(true); } break; case Offerwall_Co.Fyber: if (ofwScripts == null) { ofwScripts = transform.GetComponent <ShowOfferwallAds>(); } if (ofwScripts.ofwAd != null) { ofwScripts.ofwAd.Start(); ofwScripts.ofwAd = null; offerWallRequester = OfferWallRequester.Create(); offerWallRequester.Request(); offerWallRequester.CloseOnRedirect(false); return(true); } break; default: break; } return(false); }
// Start is called before the first frame update void Start() { //Playfab //PlayFabSettings.TitleId = titleID; //Adgem start AdGem.startSession(adGemAppId, UsesInterstitialVideos, UsesRewardVideos, UsesOfferWall); //Iron Source start string YOUR_USER_ID = SystemInfo.deviceUniqueIdentifier; IronSource.Agent.setUserId(YOUR_USER_ID); IronSource.Agent.shouldTrackNetworkState(true); IronSource.Agent.init(YOUR_APP_KEY, IronSourceAdUnits.REWARDED_VIDEO, IronSourceAdUnits.INTERSTITIAL, IronSourceAdUnits.OFFERWALL, IronSourceAdUnits.BANNER); IronSource.Agent.validateIntegration(); //Facebook start FB.Init(InitCallback, OnHideUnity); }
//This should be called when one of the following things happens: User x's out of the end card, user x's out of exitable video with no end card, uers is auto-redirected after a video finishes. private void videoAdProcessFullyCompleted() { if (AdGemPlugin.rewardMode) { //AdGemPlugin.rewardVideoReady = false; //We will try downloading the next one while the current one is playing. if (AdGem.rewardVideoFinishedPlaying != null) { AdGem.rewardVideoFinishedPlaying(); } } else { //AdGemPlugin.standardVideoReady = false; //We will try downloading the next one while the current one is playing. if (AdGem.interstitialVideoFinishedPlaying != null) { AdGem.interstitialVideoFinishedPlaying(); } } }
private IEnumerator prepareThenPlayVideo() { if (AdGem.verboseLogging) { Debug.Log("Adgem--- prepareThenPlayVideo starting"); } goAdGemCanvas.SetActive(true); goAdGemVideoCamera.SetActive(true); endCardImageObject.SetActive(false); countdownRing.SetActive(true); countdownRingBg.SetActive(true); countdownTextObject.SetActive(true); Vector3 correctVideoHolderPosition = videoHolderRect.localPosition; videoHolderRect.localPosition = new Vector3(Screen.width * 5, 0, 1); //move the video holder off screen videoPlayer.Prepare(); float prepareWaitTime = 0f; //only wait 5 seconds to prepare. while (!videoPlayer.isPrepared && prepareWaitTime < 5f) { yield return(new WaitForSeconds(0.1f)); prepareWaitTime += 0.1f; if (AdGem.verboseLogging) { Debug.Log("Adgem--- videoPlayer preparing............."); } if (AdGem.verboseLogging) { Debug.Log("Adgem--- videoPlayer.texture is null? " + (videoPlayer.texture == null)); } } yield return(new WaitForSeconds(0.05f)); if (videoPlayer.texture != null) { vidoePlayerRawImage.color = Color.white; vidoePlayerRawImage.texture = new RenderTexture(videoPlayer.texture.width, videoPlayer.texture.height, 0); videoPlayer.targetTexture = (RenderTexture)vidoePlayerRawImage.texture; xButtonWasClicked = false; goAdGemCanvas.SetActive(true); goAdGemVideoCamera.SetActive(true); //supressCurrentScene(); audioSource.volume = 0.9f; videoHolder.SetActive(true); videoPlayer.Play(); audioSource.Play(); videoHolderRect.localPosition = correctVideoHolderPosition; //move the video holder back on screen AdGemPlugin.videoIsPlaying = true; AdGemPlugin.customEndCardShowing = false; AdGemPlugin.fullScreenEndCardShowing = false; AdGemPlugin.carouselEndCardShowing = false; if (AdGem.videoAdStarted != null) { AdGem.videoAdStarted(); } currentVideoLength = ((float)videoPlayer.frameCount) / videoPlayer.frameRate;; countdownRingImage.fillAmount = 0f; countdownTimeLeft = currentVideoLength; StartCoroutine(MonitorScreenSize()); StartCoroutine(sendVideoStartedConfirmation()); //Allow next video to begin downloading if (AdGemPlugin.rewardMode) { AdGemPlugin.rewardVideoReady = false; //Debug.Log("Reward video ready set to false"); } else { AdGemPlugin.interstitialVideoReady = false; //Debug.Log("Standard video ready set to false"); } } }
private IEnumerator waitThenCallOfferWallClosed() { yield return(new WaitForSeconds(0.3f)); AdGem.offerWallClosed(); }
// Update is called once per frame void Update() { if (AdGemPlugin.videoIsPlaying) { countdownRingImage.fillAmount = (countdownTimeLeft / currentVideoLength); countdownText.text = ((int)countdownTimeLeft + 1).ToString(); countdownTimeLeft -= Time.unscaledDeltaTime; } if (Input.GetMouseButtonDown(0)) { if (xButtonObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(xButtonClickableAreaRect, new Vector2(Input.mousePosition.x, Input.mousePosition.y))) { xButtonClicked(); } else if (AdGemPlugin.fullScreenEndCardShowing) { if (AdGem.adClicked != null) { AdGem.adClicked(); } if (AdGemPlugin.rewardMode) { if (AdGem.verboseLogging) { Debug.Log("Adgem - click event being sent from adgem prefab controller - rewarded, full screen endcard"); } userClicked(AdGemPlugin.rewardVideoTrackingUrl, AdGemPlugin.rewardVideoAppStoreAppId); AdGemManager.staticRef.fireEventEndpoint("click", "rewarded-video", AdGemManager.rewardedVideoCacheId); } else { if (AdGem.verboseLogging) { Debug.Log("Adgem - click event being sent from adgem prefab controller - non-rewarded, full screen endcard"); } userClicked(AdGemPlugin.standardVideoTrackingUrl, AdGemPlugin.standardVideoAppStoreAppId); AdGemManager.staticRef.fireEventEndpoint("click", "nonrewarded-video", AdGemManager.interstitialVideoCacheId); } } else if (AdGemPlugin.carouselEndCardShowing) { //add carousel rectTransformUtility check if click is on carousel, ignore. if (RectTransformUtility.RectangleContainsScreenPoint(customEndCardPanelRect, new Vector2(Input.mousePosition.x, Input.mousePosition.y))) { if (AdGem.adClicked != null) { AdGem.adClicked(); } if (AdGemPlugin.rewardMode) { userClicked(AdGemPlugin.rewardVideoTrackingUrl, AdGemPlugin.rewardVideoAppStoreAppId); } else { userClicked(AdGemPlugin.standardVideoTrackingUrl, AdGemPlugin.standardVideoAppStoreAppId); } } } else if (AdGemPlugin.customEndCardShowing) { if (RectTransformUtility.RectangleContainsScreenPoint(downloadButtonRect, new Vector2(Input.mousePosition.x, Input.mousePosition.y))) { if (AdGem.adClicked != null) { AdGem.adClicked(); } if (AdGemPlugin.rewardMode) { if (AdGem.verboseLogging) { Debug.Log("Adgem - click event being sent from adgem prefab controller - rewarded, custom endcard"); } userClicked(AdGemPlugin.rewardVideoTrackingUrl, AdGemPlugin.rewardVideoAppStoreAppId); AdGemManager.staticRef.fireEventEndpoint("click", "rewarded-video", AdGemManager.rewardedVideoCacheId); } else { if (AdGem.verboseLogging) { Debug.Log("Adgem - click event being sent from adgem prefab controller - non-rewarded, custom endcard"); } userClicked(AdGemPlugin.standardVideoTrackingUrl, AdGemPlugin.standardVideoAppStoreAppId); AdGemManager.staticRef.fireEventEndpoint("click", "nonrewarded-video", AdGemManager.interstitialVideoCacheId); } } } } }