Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float GetPixelToPointFactor()
- {
- BannerView banner = new BannerView(BannerId, AdSize.Banner, AdPosition.TopLeft);
- return AdSize.Banner.Width / banner.GetWidthInPixels();
- }
- public float GetScaleFactor()
- {
- float scaleFactor = 0;
- if (scaleFactor == 0) scaleFactor = GetPixelToPointFactor();
- return scaleFactor;
- }
- public void RequestBanner()
- {
- AdSize adSize = new AdSize(300, 250);
- int w;
- int h;
- if (Screen.dpi < 250)
- {
- w = 280;
- h = 200;
- }
- else
- {
- w = 75;
- h = 50;
- }
- int xLocation = (int)(((float)Screen.width * 0.3125f) * GetScaleFactor());
- int yLocation = (int)(((float)Screen.height / 2f) * GetScaleFactor());
- if (xLocation < 0) xLocation = 0;
- int adX = xLocation - (w / 2);
- int adY = yLocation - (h / 2);
- bannerView = new BannerView(BannerId, AdSize.MediumRectangle, adX, adY);
- AdRequest request = new AdRequest.Builder().Build();
- bannerView.LoadAd(request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement