user6660923
user6660923

Reputation:

AdMob bannerview changing position

I am working on a unity2d game in which I have been asked to put admob bannerview. I read the tutorial and everything put in place. Now the difficult part is, I want to change the existing bannerview position from top to bottom when I navigate from Home page to GamePlay screen without destroying and recreating ta new bannerview object.

     #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);

I can shift bannerview position by calling bannerView.Hide() and Destroy() and creating a brand new bannerView. Doing so, creating unnecessary lag in loading new Request.

    bannerView.Hide (); 
    bannerView.Destroy();

I want to eliminate this delay by shifting existing bannerview position,

But I couldn't find any method in bannerview class to shift x/y position.

Upvotes: 1

Views: 1598

Answers (1)

Kenshin
Kenshin

Reputation: 1030

You have to destroy and create a new bannerview instance by setting AdPosition.Bottom or AdPosition.Top. As of now, there is no method available in BannerView class to shift position.

bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);

Upvotes: 1

Related Questions