- Home /
Getting Device Screen Height and width in inches
I'm trying to get the get the device height and width in inches and using this method. (Screen.currentresolution.width)/ Screen.dpi and Screen.currentresolution.height but this doesn't seem to work for me , Can you tell what's wrong and suggest the right thing. thank you .
Answer by Rajeesh_AR · Aug 19, 2016 at 09:25 AM
Hi @sourav13
float ScreenWidthInch = Screen.width / Screen.dpi;
float ScreenHeightInch = Screen.height / Screen.dpi;
This will give the physical width and height of the device screen in inches.
You can view the result in the unity editor itself, if you debug the values.
Answer by tanoshimi · Aug 19, 2016 at 09:14 AM
Assuming you're talking about Android devices, pre Unity 5.1 Screen.dpi is an average of xdpi and ydpi. Now it's the densityDPI. If you want more accurate method, refer to the following http://forum.unity3d.com/threads/screen-dpi-on-android.414014/
Your answer
Follow this Question
Related Questions
Screen.width and Screen.height sometimes flipped for Android 1 Answer
When are Screen.width and Screen.height updated after changing the Screen.orientation value? 0 Answers
Unity 3.5.7 Android Screen returns the wrong value? 0 Answers
Make area adapt to screen size 1 Answer
Can't work with screen.width / height 3 Answers