Search Unity

Force letterboxing on iPhone X

Discussion in 'iOS and tvOS' started by HNKMaster, Apr 10, 2018.

  1. HNKMaster

    HNKMaster

    Joined:
    Aug 31, 2012
    Posts:
    19
    I'm having issues with the notch and safe areas on iPhone X, mostly because our app was designed for Android and pre-X iPhone devices. I was reading old apps are letterboxed on X, but for some reason newer apps have to be designed with X beforehand. Is there a way to force letterboxing inside the safe area?

    I'm using the last xCode version.
     
  2. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    You could check with iOS.Device.generation if it is an iPhone X, but as you mentioned Android, there are a several Android phones coming with notches, so you will need other checks which I have no idea over.

    Notches are a stupid idea.
     
  3. Sailendu

    Sailendu

    Joined:
    Jul 23, 2009
    Posts:
    254
    There is no way to force letter-boxing if you build your app with Xcode 9 or newer. You can use black bars in the UI on both sides to make it look like letter-boxed. But I am not sure if Apple will approve that. Notches are the stupidest thing I've ever seen since smartphones came out.
     
    User340 likes this.
  4. HNKMaster

    HNKMaster

    Joined:
    Aug 31, 2012
    Posts:
    19
    Welp, what a sad thing :(

    I'm doing a system which is gonna resize the canvas based on which device is being run. As I don't have a iPhone X, what are the possible names to get with SystemInfo.deviceModel?

    EDIT: After some researching, I found the possible names for iPhone X devices here: https://www.theiphonewiki.com/wiki/Models#iPhone
    Now I'll wait for someone with an X for testing.
     
    Last edited: Apr 13, 2018
  5. Sailendu

    Sailendu

    Joined:
    Jul 23, 2009
    Posts:
    254
    You can use this to detect if the device is an iPhone X in Unity.

    Code (CSharp):
    1.     if (UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhoneX)
    2.     {
    3.         // Do iPhone X stuff here
    4.     }
     
  6. totsboy

    totsboy

    Joined:
    Jul 12, 2013
    Posts:
    253
    I can test for you if you want.
    I had the same issue and what I did was basically the same as I already do on Android superwidescreen devices, I check the aspect ratio to see if it's wider than 16:9 and then add the letterbox.
    The problem with using iOS.DeviceGeneration.iPhoneX is that if/when apple releases another device with similar aspect ratio you will have to update the game again.
     
  7. unity_L6xmfNFURMtf4Q

    unity_L6xmfNFURMtf4Q

    Joined:
    May 29, 2018
    Posts:
    3
    If you wanted to try it on an iphone x device and you dont have one , you can try using a simulator