Search Unity

Is Screen.dpi supported?

Discussion in 'Windows' started by DanielQuick, Jul 25, 2013.

  1. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Hi all,

    I'm wondering if Windows Phone deployment does not support Screen.dpi or if it is just my device (Nokia Lumia 521) as it always returns 0.

    Are there any other ways of determining the physical size of the device's screen?

    Regards,
    Daniel Quick
     
  2. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,814
    Bump.

    Also wondering this on Desktop too.
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    Now that's an old post.

    It works on windows phone as of Unity 5 or something.

    On Standalone player it reports logical DPI.
     
  4. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,814
    Okay, because I am getting customer complaints stating that the buttons are super tiny. If I switch to Physical Scaling (dpi) will that fix the problem. You said it works on Windows Phone and Standalone, but what about Windows Desktop 8.1/10?
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    1,961
    Windows Desktop is Standalone.
     
  6. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,814
    Ok, it's just confusing as I don't know the terminology for the different platforms:
    - PC Standalone
    - Windows Desktop
    - Windows Phone

    I had assumed he was referring to PC Standalone, but thanks for the clarification.

    Also, what's logical DPI? Is it not true DPI?
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    It should be working. On Windows Store on desktop you'll get physical DPI.

    Logical DPI is the scaling value set in display properties multiplied by 96. For example, if the system scale level is 100%, logical DPI will be 96. If the system scale level is 150%, logical DPI will be 144.

    Physical DPI is the actual number of pixels per inch.
     
    Salvador-Romero likes this.
  8. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,814
    Okay, so to clarify, if I set the Canvas to Physical Units, will the buttons remain the same size regardless of scale mode in the display properties?
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    It should... though I'm not exactly convinced that you really want the buttons to be sized identically on a phone and on a PC. User will have a phone much closer to his face.

    I'd suggest testing on various form factors yourself.
     
  10. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,814
    Right, but I'm not target Windows Phone.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    What I meant was that if your customer complains about buttons being too small, you should look at it for yourself instead of blindly changing UI settings and relying on a forum answer for it to work correctly.
     
    HonorableDaniel likes this.
  12. Salvador-Romero

    Salvador-Romero

    Joined:
    Jan 21, 2014
    Posts:
    20
    That was great to find since I'm stumbling on it. Thanks.

    Alas, I find frustrating that there is nothing about logical / physical dpi definition in the documentation: https://docs.unity3d.com/ScriptReference/Screen-dpi.html
    Neither there is anything about how this function behaves in other platforms (i.e.: Mac, Linux, iOS, Android... -Well, there is a related discussion in Android, but nothing more).

    Would you please care to elaborate? Maybe ping the documentation team.
    Thanks!