【发布时间】:2019-01-11 15:58:30
【问题描述】:
我已关注 Google Admob step by step tutorial 在我的 3D Unity 游戏上实施插页式广告,但在我的设备上运行游戏时未显示插页式广告。
你知道我的代码出了什么问题,以及如何解决吗?
广告脚本:
private InterstitialAd interstitial;
static int loadCount = 0;
bool GameHasEnded = false;
float RestartDelay = 1.5f;
private void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-3940256099942544/1033173712";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
this.RequestInterstitial();
if ((loadCount % 3) == 0) // only show ad every third time
{
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
}
}
}
void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().path);
loadCount = loadCount + 1;
}
private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd.
this.interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
this.interstitial.LoadAd(request);
}
【问题讨论】: