Esempio n. 1
0
    public IEnumerator ShowGoogleAd()
    {
#if UNITY_EDITOR
        string adUnitId = "unused";
#elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-1516564916828689/2110319251";
#else
        string adUnitId = "unexpected_platform";
#endif

        if (!doAds)
        {
            Debug.Log("no ads:" + doAds);
            yield break;
        }
        if (requestedFullscreenAd)
        {
            Debug.Log("already request");
            yield break;
        }
        requestedFullscreenAd = true;

        fullscreenAd             = new InterstitialAd(adUnitId);
        fullscreenAd.OnAdClosed += OnFullScreenAdClosed;
        fullscreenAd.LoadAd(new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator)
                            .AddTestDevice("FFEF7CF84A9D934ED6146FA94F3925E3").Build());

        while (!fullscreenAd.IsLoaded())
        {
            yield return(new WaitForEndOfFrame());
        }

        UIDeathScreen ds = FindObjectOfType <UIDeathScreen>();
        while (ds == null)
        {
            yield return(new WaitForSeconds(2f));

            ds = FindObjectOfType <UIDeathScreen>();
        }

        fullscreenAd.Show();
        requestedFullscreenAd = false;
    }
Esempio n. 2
0
 private void Awake()
 {
     uiController = GameObject.Find("UI").GetComponent <UIDeathScreen>();
 }