Determine Physical Screen Size - Screen.dpi Accuracy?

Hi Everyone,

A game that I’m working on is pretty fast paced and it became obvious early in development that a single touch point would not be enough (in terms of accuracy) and not many devices support ‘contact patches’

So I created my own contact patches based on averages taken across a number of devices & players.

But this still wasn’t good enough, so I scaled the contact patches based on screen size and interaction across a multitude of devices and players is vastly improved.

In my scenario, I’m using Screen.height / Screen.dpi to get the screen height in inches, then scaling the contact patches accordingly. I have some fallback values (if Screen.dpi is zero) but they’re not ideal for smaller devices (i.e. phones) although there is not a lot I can do about that (SystemInfo.deviceType & Application.isMobilePlatform are not granular enough)

So I was wondering on the accuracy of Screen.dpi given that the documentation specifically references Android not being entirely accurate on some devices.

I’m not scaling the UI here, so accuracy doesn’t have to be exact. I do have a larger margin of error, but I’m still wondering how others have found the accuracy of Screen.dpi on Android, iOS & Windows.

Or… is there a better way (that I’ve missed) to determine the physical screen size in Unity 2020?

any update regarding this?

I’m not aware of anything new in Unity that would help, but maybe there is and I’m just not aware. I suspect the limitation is with actual hardware and\or operating systems, rather than Unity.

I wrote an article on the input system (for the game in question) that briefly covers this topic (in step 2)…

If you find a better approach, please do share. Good luck!

I think I’ll just set a fixed dpi manually if it’s possible. Will read your article. Thank you

1 Like