I’m using the AdMob Unity Plugin to show banners, this is simple to configure and works, except custom positions don’t seem to match the screen pixels.
I’m wanting a horizontally centred banner somewhat below the top of the screen. This is the code I’d expect to use to achieve that:
bannerView = new BannerView(bannerAdUnitId, AdSize.Banner, (Screen.width - AdSize.Banner.Width) /2, 80);
But the banner size is defined in the plugin as AdSize Banner = new AdSize(320, 50); and yet, a 320 unit wide banner nearly fills the width of my 1080 device.
As such, (Screen.width - AdSize.Banner.Width) /2 does not give the correct left padding to centre the Ad.
How are these AdSize units mapped to screen pixels?
Ok, so I think I’ve found a hacky solution (from various posts around the interwebs)
Seems AdMob gives different size banners based on the device’s dpi. The following is working ok on my devices, not sure how applicable this is for other devices though… The code I’m using is: