【发布时间】:2017-08-23 17:29:22
【问题描述】:
我基本上复制粘贴并稍微修改了这个谷歌移动广告官方分支的演示项目广告设置,我的横幅广告正常显示,但没有插页式广告出现 - 无论如何。
这就是我所做的,使用我的AdManager static class:
这个InitializeAds()在游戏开始后被调用:
public static void InitializeAds()
{
MobileAds.Initialize(appID);
}
当然,每一个有广告的关卡,在其Start() 方法中都有以下GetSomeAdRequests()。
public static void GetSomeAdRequests()
{
AdRequestBANNER = CreateAdRequest();
AdRequestINTERST = CreateAdRequest();
}
public static AdRequest CreateAdRequest()
{
AdRequest request = new AdRequest.Builder().Build();
return request;
}
不用说,我使用的是 Google 提供的测试视频和横幅 ID。
接下来,我的RequestInterstitial:
public static void RequestInterstitial()
{
// These ad units are configured to always serve test ads.
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = videoID;
#else
string adUnitId = "unexpected_platform";
#endif
// Clean up interstitial ad before creating a new one.
if (interstitial != null)
{
interstitial.Destroy();
}
// Create an interstitial.
interstitial = new InterstitialAd(adUnitId);
// Register for ad events.
interstitial.OnAdLoaded += HandleInterstitialLoaded;
interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
interstitial.OnAdOpening += HandleInterstitialOpened;
interstitial.OnAdClosed += HandleInterstitialClosed;
interstitial.OnAdLeavingApplication += HandleInterstitialLeftApplication;
// Load an interstitial ad.
interstitial.LoadAd(AdRequestINTERST);
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
最后AdRequestINTERST 是:
private static AdRequest adRequestINTERST;
public static AdRequest AdRequestINTERST
{
get
{
if (adRequestINTERST == null)
{
adRequestINTERST = CreateAdRequest();
}
return adRequestINTERST;
}
set
{
adRequestINTERST = value;
}
}
以这种方式实现以确保request 从不为空。
现在,我确实花了很多时间来初始化 vid,因为它应该在启动时加载,但它仍然没有做任何事情。没有错误,没有冻结。
在编辑器播放中,我使用Debug.Log 对其进行了测试,它到达了实际调用广告的代码。它只是不显示,而横幅广告工作正常。
有什么想法吗?
【问题讨论】:
-
我在上面的代码 sn-p 中没有看到任何用于展示广告的代码。 if (interstitial.IsLoaded()) { interstitial.Show(); }
-
这是一个很好的提示,但仍然没有运气:/ 尽管如此,我还是编辑了这个问题。