Advertisement.IsReady()在统一广告中始终返回false

时间:2019-02-24 09:51:17

标签: unity3d unityscript unityads

我已经统一开发了一款游戏,并且已经在游戏中放置了Unity广告,但是我的Advertisement.IsReady()总是返回false

私有字符串AndroidGameId =“ xxxxx”;

  public void ShowRewardVideo()
    {
        if (Application.internetReachability != NetworkReachability.NotReachable)
        {
            if (Advertisement.IsReady())
            {
                Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleReward });
            }
            else
            {
                VideoLoadingUI.SetActive(true);
                if (!Advertisement.isInitialized)
                {
                    Advertisement.Initialize(AndroidGameId, false);
                }
                StartCoroutine(waitAdLoad());
            }
        }
        else
        {
            LoadInternetFaildUI.SetActive(true);
        }
    }
    private void HandleReward(ShowResult result)
    {
        switch (result)
        {
            case ShowResult.Finished:
                AddLifes(1);
                break;
            case ShowResult.Skipped:
                Advertisement.Initialize(AndroidGameId, false);
                break;
            case ShowResult.Failed:
                VideoLoadingUI.SetActive(false);
                VideoLoadingUIFaild.SetActive(true);
                Advertisement.Initialize(AndroidGameId, false);
                break;
        }
    }
    IEnumerator waitAdLoad()
    {
        for (int i = 0; i <= 5; i++)
        {
            yield return new WaitForSeconds(1f);

            if (Advertisement.IsReady())
            {
                break;
            }
        }
        VideoLoadingUI.SetActive(false);
        if (Advertisement.IsReady())
        {
            Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleReward });
        }
        else
        {
           VideoLoadingUIFaild.SetActive(true);
            if (!Advertisement.isInitialized)
            {
                Advertisement.Initialize(AndroidGameId, false);
            }
        }
    }

有人知道为什么会这样吗?

0 个答案:

没有答案