我有一个 Google AdMob 横幅,我想将其显示在自定义位置。下面的行在我的中工作得很好...
...
bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
...
尽管当我想将横幅放置在自定义位置时,它永远不会显示在屏幕上。我正在做:
...
int w = 0;
int h = Screen.height/2;
bannerView = new BannerView(adUnitId, AdSize.Banner, w, -h);
...
我做错了什么?
AdMob 横幅广告的文档可以在此处找到:https://developers.google.com/admob/unity/banner
非常感谢任何帮助! :)
最佳答案
正如您提供的文档所述:
The top-left corner of the BannerView will be positioned at the x and y values passed to the constructor, where the origin is the top-left of the screen.
您的错误可能是您向 y 参数传递了负值,导致 BannerView 位于屏幕上边框之外。
因此,如果您希望横幅 View 仅按高度居中,您的代码应如下所示:
...
int w = 0;
int h = Screen.height/2;
bannerView = new BannerView(adUnitId, AdSize.Banner, w, h);
...
请注意,您没有考虑 BannerView 的实际高度。为了让它居中并考虑到它的高度,这应该可行:
...
int w = 0;
int bannerHeight = 50; //Because AdSize.Banner measures 320x50
int h = Screen.height/2 - bannerHeight/2;
bannerView = new BannerView(adUnitId, AdSize.Banner, w, h);
...
关于unity-game-engine - 如何在屏幕中央显示 Unity Google AdMob 横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52155327/