【问题标题】:Unity Ads don't always play. Sometimes I see an ad. Sometimes I don'tUnity 广告并不总是播放。有时我会看到一个广告。有时我不
【发布时间】:2022-08-06 02:50:45
【问题描述】:

我在手机上玩我的游戏。有时广告会显示、完成,其余代码运行顺畅。其他时候广告不显示,没有其他事情发生。游戏不继续。怎么修?

我在手机上玩我的游戏。有时广告会显示、完成,其余代码运行顺畅。其他时候广告不显示,没有其他事情发生。游戏不继续。怎么修?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class AdsManager : MonoBehaviour, IUnityAdsListener, IUnityAdsInitializationListener
{
    public static AdsManager instance;
    public CarController carController;

    string gameID = \"4818077\";

    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        //carController = GetComponent<CarController>();
    }
    // Start is called before the first frame update
    void Start()
    {
        Advertisement.Initialize(gameID);
        Advertisement.AddListener(this);
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void ShowAd()
    {
        if (Advertisement.IsReady(\"Interstitial_Android\"))
        {
            Advertisement.Show(\"Interstitial_Android\");
        }
    }

    public void ShowRewardedAd()
    {
        if (Advertisement.IsReady(\"Rewarded_Android\"))
        {
            Advertisement.Show(\"Rewarded_Android\");
        }
    }

    public void OnUnityAdsReady(string placementId)
    {
        Debug.Log(\"Unity Ads ready.\");
    }

    public void OnUnityAdsDidError(string message)
    {
        Debug.Log(\"Unity Ads error.\");
        GameManager.instance.ReloadLevel();
    }

    public void OnUnityAdsDidStart(string placementId)
    {
        Debug.Log(\"Unity Ads ready start.\");
    }

    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
        if (GameManager.instance.respawned == true)
        {
            GameManager.instance.bigCountdown.SetActive(true);

        }
        else
        {
            GameManager.instance.ReloadLevel();
        }
    }

    void OnDestroy()
    {
        Debug.Log(\"DestroyAdController\");
        Advertisement.RemoveListener(this);
    }

    public void OnInitializationComplete()
    {
        throw new System.NotImplementedException();
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        throw new System.NotImplementedException();
    }
}

    标签: unity3d


    【解决方案1】:

    我也有同样的问题,请问您找到解决方案了吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多