Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
Dismiss Notice
Act now to save. The price for Unity Pro will be increasing on October 13, 2022, 13:00 UTC. Switch to an annual plan before this time to lock in your current price. If no action is taken, you will remain on the month-to-month plan at the new price.

iPhone 6 Plus screen.width?

Discussion in 'iOS and tvOS' started by DaddyMac, Sep 18, 2014.

  1. DaddyMac

    DaddyMac

    Joined:
    Sep 18, 2014
    Posts:
    13
    Is screen.width for the 6 plus 1920 or 2208?
     
  2. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    372
    The screenshot requirement size is 2208 x 1242 for iPhone 6.
    But i also thought the phones resolution was supposed to be 1920 x 1080, so also confused.
     
  3. DaddyMac

    DaddyMac

    Joined:
    Sep 18, 2014
    Posts:
    13
    Yes, I found that as well, jesusluvsyooh. I use screen.width a lot, but had used 1920 to detect the 6 Plus, and suddenly I am thinking it should have been 2208.
     
  4. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    Several websites says the iPhone 6 plus renders at 2208 x 1242 pixels UNLESS you use Metal which has direct access to the native resolution of the screen. Which (if really true) would mean than any game made with Unity 4 will have a huge performance penalty to deal with because Metal will be supported by Unity 5 only.

    BTW: It also seems the iPhone 6 UPSCALES from a lower rendering resolution without Metal.
     
  5. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251

    Yes, apparently you should target 2208 size. See this handy link here
     
  6. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251

    But can it downscale? If I build sprites for 2208, then what of iPhone 5 & 4S?
     
  7. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    723
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,347
    That's the screen resolution, though, which is downscaled. The native resolution (what the GPU is actually rendering) seems to be 1242 x 2208 from everything I've read.

    --Eric
     
  9. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    Unless Unity is upgraded to use Metal which is the only way to access the screen directly, but according to blog posts of Aras Unity 5 will use Metal.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,347
    Say you weren't using Metal, and you rendered at 621x1104 for performance reasons, would it be upscaled to 1242x2208 and then downscaled to 1080x1920? Crazy. ;)

    --Eric
     
    eelstork likes this.
  11. JJC1138

    JJC1138

    Joined:
    Feb 23, 2012
    Posts:
    89
    I just did a little test and with a 4.5.4p1 project running on an iPhone 6 Plus I'm getting:
    Screen.width = 1920
    Screen.height = 1080
    Screen.dpi = 480

    That DPI looks perplexing to me. I'd expect it to be the true DPI of the display (401) if the screen dimensions are the true screen resolution (1920x1080) but also since apparently we're rendering at the full virtual framebuffer size shouldn't the width and height be reported as 2208x1242 and the DPI be reported as 461?
     
  12. JJC1138

    JJC1138

    Joined:
    Feb 23, 2012
    Posts:
    89
    Hmm, I just tested an iPad mini with Retina Display and that is also reporting an inaccurate DPI (260, when it should be 326). It looks like the code that calculates the DPI in DeviceSettings.mm simply hasn't been updated for the newer devices. I'll file a bug tomorrow.

    For the resolution, though, I'm not entirely convinced that Unity is actually rendering at 2208x1242. Unity has always been able to render at non-native resolutions on iOS, so I wonder if on iPhone 6 Plus we're simply rendering at 1920x1080, and then it's being scaled up to 2208x1242 by the OS for compositing with overlays and such, and then scaled back down to 1920x1080 for display? Presumably the answer to that question is in DisplayManager.mm if anyone less tired than me feels like digging through it. :)
     
    eelstork likes this.
  13. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    Try to make a screenshot. I've read that screenshots are 2208x1242
     
  14. JJC1138

    JJC1138

    Joined:
    Feb 23, 2012
    Posts:
    89
    Yes they are, but that doesn't really tell you what resolution the engine is rendering at, since it could be being scaled up to be composited with overlays like Control Center. Old apps like Google Maps that haven't been updated for the new screen sizes also produce 2208x1242 screenshots.
     
  15. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    This german article (of the most serious german computer magazine) says that Metal is required to render at native screen resolution and games without using Metal will lose 3D performance due to rendering at an unnecessary higher resolution. http://www.heise.de/ct/artikel/Appl...chirmaufloesungen-2394857.html?artikelseite=2

    I doubt that system overlays are done at 2208x1242, beside that all (even new ones) apps should produce screenshots in 2208x1242 - could you please download one of those metal game demos and make a screenshot, would be interesting to see if it will look like being upscaled for the screenshot resolution or if it will be in 1920x1080
     
  16. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html#//apple_ref/doc/uid/TP40014205-DontLinkElementID_1

    "or OpelGL ES" - hence Unity should render at 1920x1080.

    false alarm :)
     
    JJC1138 likes this.
  17. Smilediver

    Smilediver

    Joined:
    May 5, 2011
    Posts:
    72
    Just chiming in to confirm that from 4.5.4p1 and 5.0 for iPhone 6+ Unity by default should use 1920x1080, and this goes both for OpenGL ES and Metal. This is the correct one, because we want to skip downscaling step for performance reasons. If you see otherwise, submit a bug report. :)

    P.S. incorrect DPI is a bug.
     
    Moonjump, Thavron and JJC1138 like this.
  18. JJC1138

    JJC1138

    Joined:
    Feb 23, 2012
    Posts:
    89
    Thanks very much for the confirmation. I submitted a bug last night with a (slightly elaborate) fix for the DPI bug. I tried to make the function more future proof by guessing the DPI for unknown devices based on the screen width in points as reported by the OS. I'll attach it here just in case it's useful for anyone else straight away.
     

    Attached Files:

  19. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,219
    It's great that Unity already supports native 1080! I could see this happening when I ran my game in both Standard and Zoom (pretends to be an iPhone 6 non-Plus). Everything came out identical. Which I guess means I can't test the non-Plus size on the Plus, but it also means I don't have to address Zoom mode at all. Good!

    And screenshots are definitely scaled up (as is the game any time a system overlay appears, I believe) because my game is non-AA, and the screenshots clearly have enlarged pixels yet with soft edges. Clearly scaled up.
     
  20. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    Resurfacing this thread. I'm seeing a different behaviour than I had on Unity 5.3. When I launch my app on iOS, one of my first monobehaviour scripts that runs which happens to be a ui management related class, reads Screen.width during Awake, and on an iPhone 6S Plus I get a width of: 2208. Then I start logging Screen.width from OnGUI, for about 4 update calls to OnGUI I get 2208. Then it changes to 1920. From that point onward it always remains 1920. This is really bad, cause now I have no way of knowing which resolution to listen to.

    I now need to add some super hackish code that listens for a change of the screen resolution before proceeding and rendering my UI (Im not using the new built in Unity UI btw). But I can't think of a good way to do this that will work cross-platform or work for all device types, like I'd have to add an iPhone Plus only hack. Oh man.

    I'm using 5.4.0p4, the 6S Plus is running iOS9.3.4.
     
  21. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    anyone from Unity know if there's an event or something I can listen to that can reliably tell me when it's safe to start reading Screen.width?
     
  22. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    I've created a bug report, I'll post the tracking number when I get the confirmation email. But I confirmed this bug by making the absolute simplest example project. Just start logging the Screen.width and run this on an iPhone 6S Plus, you'll see the value report 2208 for a 3-4 updates then change to 1920. I have no decent way of knowing when I can reliably read this value.
     
  23. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    issue id: 829434
     
  24. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,183
    try orientation change event / don't know if its exposed in untiy...
     
  25. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    Thanks I appreciate the suggestion but the device is not changing orientation. It's simply starting out with the full native and non-scaled device resolution that the iPhone 6S Plus has at 2208 width, but then changes to 1920. The Plus devices do some unusual hardware scaling which is probably the real root of this problem. I'm guessing that during the iOS application delegate launch phase, or perhaps while the splash/launch images need to be on screen it's rendering and reporting 2208, then when the OpenGL or Metal rendering view kicks off it's using 1920. In that small window is my problem. I'm happy to have a small delay before reading the value but I need to know when it's made the change, and to be able to have that code run in a way thats platform and device independent.
     
  26. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,183
    it might still fire, despite the device not being physically rotated
    then there is
    Code (CSharp):
    1. NSApplicationDidChangeScreenParametersNotification
    for default notification center..
     
  27. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    I've been advised that the issue has been fixed in the 5.5 beta.. however I'm hoping Unity decide to back port the fix to the current stable version of Unity because no one can rely on use a beta for live production. It has far too much potential for volatile changes and to encounter other bugs, especially when you need to support multiple platforms. Otherwise I'm thinking this new beta release strategy could basically be back to the way Unity used to be a couple of years back where you had to wait months for a bug fix to make it in to the stable build.
     
  28. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,589
    I would guess that they will fix it in a patch release of 5.4.x too.
     
  29. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    yea I hope so.. thx =)
     
  30. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    448
    Hey all, big thanks to Unity who back ported the resolution fix to 5.4.1p1. Confirmed that the fix is working well, cheers! Jason :)
     
    VIC20 likes this.
  31. Unity_United

    Unity_United

    Joined:
    Apr 5, 2017
    Posts:
    2
    UNITY 5.4.0 , Screen.width & Screen.height returning 960 & 640 respectively on iPhone 5 & 6, when tested on device.
    Also, the Default Splash Screen of UNITY is stretched or squeezed accordingly...
     
unityunity