예제 #1
0
    private IEnumerator RefreshInternetConnection()
    {
        float timeCheck = 1.0f;//will check google.com every one seconds
        float t1;
        float t2;

        while (!connected)
        {
            WWW www = new WWW("http://google.com");
            t1 = Time.fixedTime;
            yield return(www);

            if (www.error == null)//if no error
            {
#if UNITY_ANDROID
                Advertisement.Initialize("1415243"); // initialize Unity Ads.
                UnityAdsHelper.Initialize();         // initialize Unity Ads.
#elif UNITY_IOS
                UnityAdsHelper.Initialize();         // initialize Unity Ads.
#endif

                connected = true;

                break;//will end the coroutine
            }
            t2 = Time.fixedTime - t1;
            if (t2 < timeCheck)
            {
                yield return(new WaitForSeconds(timeCheck - t2));
            }
        }
    }
예제 #2
0
    IEnumerator Start()
    {
        if (!UnityAdsHelper.isSupported)
        {
            yield break;
        }
        else if (!UnityAdsHelper.isInitialized)
        {
            UnityAdsHelper.Initialize();
        }

        string placementName = string.IsNullOrEmpty(placementId) ? "the default ad placement" : placementId;

        _startTime = Time.timeSinceLevelLoad;

        while (!UnityAdsHelper.isInitialized)
        {
            if (initTimeout > 0 && Time.timeSinceLevelLoad - _startTime > initTimeout)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to initialize in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", placementName));
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");

        _startTime = Time.timeSinceLevelLoad;

        while (!UnityAdsHelper.IsReady(placementId))
        {
            if (showTimeout > 0 && Time.timeSinceLevelLoad - _startTime > showTimeout)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to be ready in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", placementName));
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log(string.Format("Ads for {0} are available and ready.", placementName));

        UnityAdsHelper.ShowAd(placementId);
    }
예제 #3
0
    public void Submit()
    {
        string gameId         = null;
        bool   enableTestMode = false;

        if (gameIdField)
        {
            gameId = gameIdField.text;
        }
        if (testModeToggle)
        {
            enableTestMode = testModeToggle.isOn;
        }

        UnityAdsHelper.Initialize(gameId, enableTestMode);
        SceneManager.LoadScene("UnityAdsExample");
    }
예제 #4
0
    void Start()
    {
        _button = GetComponent <Button>();

        if (_button)
        {
            _button.onClick.AddListener(ShowAd);
        }

        _keyCooldownTime   += name + gameObject.GetInstanceID().ToString();
        _rewardCooldownTime = GetCooldownTime();

        if (!UnityAdsHelper.isInitialized)
        {
            UnityAdsHelper.Initialize();
        }
    }
예제 #5
0
    private IEnumerator ShowAddWhenReady(E_REWARD _rewardID)
    {
        while (!Advertisement.IsReady("rewardedVideo"))
        {
            Advertisement.Initialize("1415243");
            UnityAdsHelper.Initialize();
            yield return(null);
        }

        var options = (_rewardID == E_REWARD.UPGRADE) ?
                      new ShowOptions {
            resultCallback = OnUpgrade
        } :
        new ShowOptions {
            resultCallback = OnLvlEndCoins
        };

        Advertisement.Show("rewardedVideo", options);
    }
 void Start()
 {
     UnityAdsHelper.Initialize();
 }