Exemplo n.º 1
0
    public void RequestInterstitialNoShow(AdPlacementType placementType, InterstitialDelegate onAdLoaded = null, bool showLoading = true)
    {
        //if (DoNotShowAds(placementType) || !HasEnoughTimeBetweenInterstitial()) //skip checking interstitial time so we can use this function for preloading interstitial ads
        if (DoNotShowAds(placementType))
        {
            onAdLoaded?.Invoke(false);
            return;
        }
        if (isLoadingInterstitial)
        {
            Debug.LogWarning("Previous interstitial request is still loading");
            onAdLoaded?.Invoke(false); //added this so game can continue even with interstitial not finished loading
            return;
        }
        if (showLoading)
        {
            Manager.LoadingAnimation(true);
        }
        StartCoroutine(CoRequestInterstitialNoShow(placementType, onAdLoaded, showLoading));
        timeLastShowInterstitial = time;

        /*switch (CurrentAdNetwork)
         * {
         *  case CustomMediation.AD_NETWORK.Unity:
         *      UnityAdsManager.instance.RequestInterstitialNoShow(CustomMediation.GetUnityPlacementId(placementType), onAdLoaded, showLoading);
         *      break;
         *  case CustomMediation.AD_NETWORK.FAN:
         *      FacebookAudienceNetworkHelper.instance.RequestInterstitialNoShow(CustomMediation.GetFANPlacementId(placementType), onAdLoaded, showLoading);
         *      break;
         * }*/
    }
Exemplo n.º 2
0
    IEnumerator CoRequestInterstitialNoShow(AdPlacementType placementType, InterstitialDelegate onAdLoaded = null, bool showLoading = true)
    {
        isLoadingInterstitial = true;
        bool isSuccess = false;
        WaitForSecondsRealtime checkInterval = new WaitForSecondsRealtime(0.05f);

        var adPriority = GetAdsNetworkPriority(placementType);

        for (int i = 0; i < adPriority.Count; i++)
        {
            bool checkAdNetworkDone     = false;
            IAdsNetworkHelper adsHelper = GetAdsNetworkHelper(adPriority[i]);
            if (adsHelper == null)
            {
                continue;
            }
            adsHelper.RequestInterstitialNoShow(placementType,
                                                (success) => { checkAdNetworkDone = true; isSuccess = success; },
                                                showLoading);
            while (!checkAdNetworkDone)
            {
                yield return(checkInterval);
            }
            if (isSuccess)
            {
                //CurrentAdNetwork = AdNetworkSetting.AdNetworks[i];
                currentAdsHelper = adsHelper;
                break;
            }
        }
        //.Log($"AdsManager: CoRequestInterstitialNoShow done {isSuccess}");
        onAdLoaded?.Invoke(isSuccess);
        isLoadingInterstitial = false;
        if (showLoading)
        {
            Manager.LoadingAnimation(false);
        }
    }