AdMob bannerview 改变位置
AdMob bannerview changing position
我正在开发一个 unity2d 游戏,有人要求我在其中放置 admob bannerview。我阅读了教程,一切都准备就绪。现在困难的部分是,当我从主页导航到 GamePlay 屏幕时,我想从上到下更改现有的横幅视图位置,而不破坏和重新创建新的横幅视图对象。
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
我可以通过调用 bannerView.Hide() 和 Destroy() 并创建一个全新的 bannerView 来移动横幅视图的位置。这样做会在加载新请求时造成不必要的延迟。
bannerView.Hide ();
bannerView.Destroy();
我想通过移动现有的横幅视图位置来消除这种延迟,
但我在 bannerview class 中找不到任何方法来移动 x/y 位置。
您必须通过设置 AdPosition.Bottom 或 AdPosition.Top 销毁并创建一个新的横幅视图实例。
截至目前,BannerView class 中没有可用的方法来移动位置。
bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
我正在开发一个 unity2d 游戏,有人要求我在其中放置 admob bannerview。我阅读了教程,一切都准备就绪。现在困难的部分是,当我从主页导航到 GamePlay 屏幕时,我想从上到下更改现有的横幅视图位置,而不破坏和重新创建新的横幅视图对象。
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
我可以通过调用 bannerView.Hide() 和 Destroy() 并创建一个全新的 bannerView 来移动横幅视图的位置。这样做会在加载新请求时造成不必要的延迟。
bannerView.Hide ();
bannerView.Destroy();
我想通过移动现有的横幅视图位置来消除这种延迟,
但我在 bannerview class 中找不到任何方法来移动 x/y 位置。
您必须通过设置 AdPosition.Bottom 或 AdPosition.Top 销毁并创建一个新的横幅视图实例。 截至目前,BannerView class 中没有可用的方法来移动位置。
bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);