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. Dismiss Notice

Game gets portrait mode, even though it's set as disabled

Discussion in 'iOS and tvOS' started by Gord10, Mar 2, 2020.

  1. Gord10

    Gord10

    Joined:
    Mar 27, 2013
    Posts:
    142
    We have a game which is supposed to change orientations in Android, but not in iOS (because we have problems with AdMob interstitials this way). The settings are set as the game works only in landscape mode in Unity. I see the same settings in XCode. But when the game scene starts after menus (game is landscape in menus), the game is able to get in portrait mode.

    Important thing to note here is that there are codes written for Android, which sets the orientation of game manually (forced to landscape for menus, auto rotation allowed for game). But these codes are inside #if UNITY_ANDROID, and I also added if(Application.platform == RuntimePlatform.Android) checks making sure those codes are only Android exclusive. I even commented the code that allows auto rotation, it still didn't work.

    I searched for every Screen. codes in Visual Studio, it seems like there aren't any codes that are missed.

    What am I missing here?

    I use Unity 2018.4.17f1.

    Screen Shot 2020-03-02 at 20.18.02.png

    Android Code.PNG
     
  2. eric_budge

    eric_budge

    Joined:
    Jul 3, 2013
    Posts:
    5
    In the PlayerSettings for iOS, try setting Default Orientation to Auto Rotation and then unchecking the Portrait options in the "Allowed orientations for Auto Rotation" section that appears? This should allow the app to be rotate in to Landscape Left and Right but not Portrait on iOS.
     
  3. Minosgraphy

    Minosgraphy

    Joined:
    Jul 16, 2020
    Posts:
    1
    Does not work for me in iOS, even if portrait mode is disabled in xCode and Unity..
    It now starts default landscape left, but if I turn the phone to portrait mode, its going to accept it...
     
  4. TheRealTomKhan

    TheRealTomKhan

    Joined:
    Apr 5, 2020
    Posts:
    1
    Did you ever get a resolution for this?

    I have a similar issue in 2019.3.15f1 where I only allow 'Landscape Right' orientation. However, when I start the game in portrait mode, the status bar is visible, the launcher screen is messed up and the game can actually begin in Portrait.

    I've recently changed the splash screen to a Storyboard, to pass Apple submission, so I think it must be related to that.
     
    carldevelopsforcoffee likes this.
  5. restauranttttt

    restauranttttt

    Joined:
    Aug 6, 2020
    Posts:
    15
    please try use both launchscreen.storyboard and splashscreen with xib files