Search Unity

Height of Banner Ads?

Discussion in 'Unity Ads & User Acquisition' started by TheFellhuhn, Feb 24, 2020.

  1. TheFellhuhn

    TheFellhuhn

    Joined:
    Feb 3, 2017
    Posts:
    42
    Is there currently any way to programatically get the size of the shown banner ad? A way that also works with split-screen apps etc?

    Without this information those banner ads are completely useless.
     
  2. TheFellhuhn

    TheFellhuhn

    Joined:
    Feb 3, 2017
    Posts:
    42
    Somewhere I read the formula

    HeightInPixels = 50 * Screen.DPI / 160

    This would only be true for ads with a height of 50. Others state that there are also ads with a height of 90 (whatever the unit is) and there is no way to check which will be chosen. So we have to assume:

    HeightInPixels = 90 * Screen.DPI / 160

    just in case. So we might have some unused space instead of ads covering content (which could remove the game from the store).

    The funny thing now is that this formula just doesn't add up. I get an ad height of 154 pixels on a 1080x1920 device and a DPI of 424. According to the above formula the DPI should be 273 or 493.

    So, how do we get the height? This is one of the most important features of banner ads.
     
  3. lastshipsails

    lastshipsails

    Joined:
    Jun 6, 2019
    Posts:
    5
    I use:

    Code (CSharp):
    1.         screenSizeInUnits = (Vector2)Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
    2.         if (Screen.height > 1900)
    3.             banner = (Vector2)Camera.main.ScreenToWorldPoint(new Vector3(320, Screen.height - 130, 0));
    4.         else if (Screen.height > 1300)
    5.             banner = (Vector2)Camera.main.ScreenToWorldPoint(new Vector3(320, Screen.height - 100, 0));
    6.         else
    7.             banner = (Vector2)Camera.main.ScreenToWorldPoint(new Vector3(320, Screen.height - 70, 0));
    Tested on small screen resolution phones and on fullhd.
    Then use banner.y.