【发布时间】:2021-02-07 14:40:20
【问题描述】:
我目前正在 Unity 2020 上单独开发一款适用于 Android 的游戏。 我已经完成了大部分游戏开发,我所要做的就是启用广告。
我参考了 Google Ads 官方文档和其他文献,但没有奏效。 具体来说,我所做的是向 Admob 注册一个新应用并发布一个新的广告 ID。此外,我正在申请在 Google Play 控制台上发布该应用。
代码与文档中介绍的完全相同;
void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
RequestBanner();
}
private void RequestBanner()
{
string adUnitId = "(correct Unit ID)";
// Create a 320x50 banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
// Create a 320x50 banner at the top of the screen.
//bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
}
测试在编辑器中显示成功,如下图;
然后我构建了游戏并在手机上进行了试用。 那么广告就不会显示了。
是因为该应用尚未发布到 Google Play 吗?
谢谢。
【问题讨论】: