[Unity3D] Trouble calculating banner size and position

511 views
Skip to first unread message

Ben@theGoodEvil

unread,
Mar 4, 2022, 10:19:17 AM3/4/22
to Google Mobile Ads SDK Developers
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 Release
Platform: Android

Best regards,
Ben
Screenshot_2.jpg
Screenshot_1.jpg
Screenshot_3.jpg

the Good Evil

unread,
Mar 16, 2022, 4:57:45 AM3/16/22
to Google Mobile Ads SDK Developers
So nobody knows anything?

Mobile Ads SDK Forum Advisor

unread,
Mar 16, 2022, 10:49:07 AM3/16/22
to deve...@thegoodevil.com, google-adm...@googlegroups.com
Hello,

I work along with Princess. Allow me to assist you in this.

With regard to your concern, the reason why the frame is too small or too big on some devices, and the banners are often shifted to the right and not within the frame is due to rendered ads can be small and the size of the padding is dependent on Ad creative that will be displayed. Also, please do note that certain creative sizes might not fill the complete size of the View and in certain cases, there will always be padding.

Regards,
Google Logo
Teejay Wennie
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2XlS90:ref

Ben@theGoodEvil

unread,
Mar 16, 2022, 11:17:55 AM3/16/22
to Google Mobile Ads SDK Developers
Hello Teejay,

thank you for your answer.
Is there a reliable way to create a frame around a banner, or is that not possible at the moment? Unfortunately, we always get the same pixel values through the plugin, even if the actual banner graphic differs from this size.

If there is no way to determine these pixel values, do you have an idea how we can separate the banner ad from the rest of the content more clearly? We don't want the user to click on the banner by accident. Without knowing the pixel sizes, this task seems impossible to me at the moment.

Thank you very much,
Ben

Mobile Ads SDK Forum Advisor

unread,
Mar 16, 2022, 10:00:42 PM3/16/22
to b...@thegoodevil.com, google-adm...@googlegroups.com

Hello Ben,

Thanks for getting back to us.

Can you try using adaptive banners? As mentioned on this guide, Adaptive banners are designed to be a drop-in replacement for both the industry standard 320x50 banner size and the smart banner format which they supersede. These banner sizes are commonly used as anchored banners, which are usually locked to the top or bottom of the screen. From the implementation notes here, there are three methods to get an ad size for adaptive which you can use to match your frame around a banner.

Regards,

Google Logo
Mark Kevin
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2XlS90:ref
Reply all
Reply to author
Forward
0 new messages