【发布时间】: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