2 回答

TA贡献2016条经验 获得超9个赞
在我的情况下,画布由于某种原因重叠了横幅,我只是在PlayerSettings -> Resolution and Presentation中取消选中“ Render Over native UI ” ,现在它工作正常。

TA贡献1796条经验 获得超4个赞
我通过销毁 QuitAd 方法中的横幅解决了这个问题:
public void QuitAd(TypeOfAd typeOfAd)
{
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Quiting Banner ad");
bannerAd.Destroy();
break;
case TypeOfAd.Interestitial:
Debug.Log("Quiting Interestitial ad");
Debug.LogError("QuitAd Interestitial Not Implemented");
break;
case TypeOfAd.RewardedVideo:
Debug.Log("Quiting RewardedVideo ad");
Debug.LogError("QuitAd RewardedVideo Not Implemented");
break;
}
}
然后我修改了 ShowAd 方法,在显示横幅之前加载它:
public bool ShowAd(TypeOfAd typeOfAd)
{
if (DataManager.instance.showAds)
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Showing Banner ad");
LoadAd(TypeOfAd.Banner); //Every time the banner is asked to be shown it will try to load before being shown.
this.bannerAd.Show(); //Will be show after loading
return true;
case TypeOfAd.Interestitial:
Debug.Log("Showing Interestitial ad");
if (this.interstitialAd.IsLoaded())
{
this.interstitialAd.Show();
return true;
}
else
{
Debug.LogWarning("Trying to show InterstitialAd but it is not loaded");
//TBD: Automaitcally load?
}
break;
case TypeOfAd.RewardedVideo:
Debug.Log("Showing RewardedVideo ad");
if (this.rewardedVideoAd.IsLoaded())
{
this.rewardedVideoAd.Show();
return true;
} else {
Debug.LogWarning("Trying to show RewardedBasedVideoAd but it is not loaded");
//TBD: Automaitcally load?
}
break;
}
return false;
}
但是,我不知道这是否是一个正确的解决方案,因为每次必须显示横幅时都会执行新的加载请求(在未显示横幅的场景之后)。
此外,这个“解决方案”只是针对同一目标的不同方法,而不是原始方法的修复。
因此,如果有人知道为什么原始代码不起作用,我将非常感谢分享这些知识。
- 2 回答
- 0 关注
- 112 浏览
添加回答
举报