Unity需要太多时间来展示

时间:2019-05-07 05:54:04

标签: unity3d

我通过单击按钮将Unity广告集成到我的游戏中,以获得奖励视频后的奖励。

但是,即使在按钮上单击200次后,Unity广告有时也不会显示,而使用vpn,广告有时会显示30至35次点击。

此外,当第一个广告加载后,随后的广告将以1-5次点击加载。 请帮助我。

这是我的代码:

using UnityEngine.UI;
using UnityEngine.Monetization;

public class adManagernew : MonoBehaviour
{

  public GameObject Connect;
  private string gameId = "";
  string placementId_rewardedvideo="rewardedVideo";
  string placementId_video="video";
  private bool testMode=false;
  // Start is called before the first frame update
  void Start()
  {
    if(Application.platform==RuntimePlatform.Android)
      gameId="";
    Monetization.Initialize(gameId,testMode);
  }

  public void ShowAd()
  {
    StartCoroutine(waitForAd());
  }

  public void ShowRewardedAd()
  {
    StartCoroutine(waitForAd(true));
  }

  IEnumerator waitForAd(bool reward=false)
  {
    string placementId=reward? placementId_rewardedvideo:placementId_video;

    while(!Monetization.IsReady(placementId))
    {
      yield return null;
    }

    ShowAdPlacementContent ad=null;
    ad=Monetization.GetPlacementContent(placementId) as 
    ShowAdPlacementContent;

    if (ad!=null)
    {
      if(reward)
      {
        ad.Show(AdFinished);
      }
      else
        ad.Show();
    }
  }

  void AdFinished(ShowResult result)
  {
    if (result==ShowResult.Finished)
    {
      //reward the player
    }
  }

  public void animinter()
  {
    Connect.GetComponent<Animator>().SetTrigger("InternetCon");
    Connect.SetActive(false);
  }
}

0 个答案:

没有答案