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 關注
- 167 瀏覽
添加回答
舉報