Hi there,
we currently have a problem with banner ads in Unity3D and don't know how to solve the problem. Our banners are displayed in the middle of the top edge of the screen.
We want to put a frame around our banners so the user can't accidentally click on the banner. This frame should clearly separate the banner visually and functionally from possible clickable objects. We use the standard banner size in our app, which is specified as 320x50 DP. To convert this size into pixels, we use the following code:
' pixels = sizeDP * (Screen.dpi / 160.0f); '
The size of a banner in pixels would be calculated as follows:
Width = 320 * (Screen.dpi / 160.0f);
Height = 50 * (Screen.dpi / 160.0f);
This calculated size is then used to adjust a UI element in Unity3D. This UI element is used in combination with a script that limits the UI to the safe area of the screen.
The problem we have now is that the frame is too small or too big on some devices. Additionally, the banners are often shifted to the right and not within the frame where we would expect.
The question now is, what can cause this behavior? Are the banners set up incorrectly? (We get this from a third provider) Is the formula wrong? Is the combination of UI element and Safe Area script wrong?
In general, the way the UI element is displayed to us is also the place where one would actually assume a central banner.
Thanks for the help. If more information is needed, please let us know.
More information:
Unity version: 2020.3.19f1
Mobile Ads Plugin Version: 6.0.2
ReleasePlatform: Android
Best regards,
Ben