How to detect if the game is running on a mobile phone

Hi. I noticed that the UI looks just a little small on phone devices. Anywhere else looks totally fine (pcs, iPads, tablets, etc.).

The problem is that, if I try to make it a little bigger so that it looks fine on phones too, it would look odd on the rest of the devices.

I was wondering if there’s a way to detect if the game is running on a phone and only then make the UI bigger with code.

As far as I know, Application.platform only gives you iOS or android, so it would not make a distinction between phones and tablets/iPads.

PS: I’m trying to avoid making 2 different versions. Besides, even if I made a custom version for android and iOS, there would still be the same problem with phones vs. tablets.

Thank you.

You can query the DPI and multiply that by the Screen.width / Screen.height pixel sizes.

Note: DPI is unreliable on certain Android systems but this DPIManager thing usually does a better job:

2 Likes