Search Unity

Unity 4.2 screen orientation lock problem

Discussion in 'Editor & General Support' started by eduilnero, Jul 29, 2013.

  1. eduilnero

    eduilnero

    Joined:
    May 9, 2013
    Posts:
    15
    Hi everybody!

    I am facing a problem with screen orientation lock since I have upgraded to Unity 4.2. In previous versions I could lock screen orientation in Build->Player Settings, but now I cannot. While trying my app (in different devices) I find that my selected screen orientation option is not being locked and, moreover, I get a crash when it changes.
    After some tests I could fix it by code but if screen orientation changes during Unity Splash screen time it still crashes... I do not know if it is a bug of this latest version or if I have not found the proper way to do it.

    Thanks in advance for your help.
     
  2. LeoCeballos

    LeoCeballos

    Joined:
    Mar 16, 2011
    Posts:
    25
    Hey Eduilnero, are you using any plugins?

    I had a problem with a plugin (Vuforia) which created its own android manifest file and that was messing up the screen orientation. I had to edit that manually. Also only started happening with 4.2
     
  3. eduilnero

    eduilnero

    Joined:
    May 9, 2013
    Posts:
    15
    Mmmmh yes I am using some plugins, I will check it out. Thank you!! :)

    EDIT:

    That was it!!!!
     
    Last edited: Jul 30, 2013
  4. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    Edited post because i found the place to edit.

    But i'm leaving this here just to show that one more guy had the same issue.
     
    Last edited: Jul 30, 2013
  5. boonyeo

    boonyeo

    Joined:
    Jun 17, 2013
    Posts:
    1
    I've having the same issue too but its coming from Plugins that have nothing to do with the presentation of the game. My best guess is they are overriding with default settings... How would you go with removing the |orientation| component of the manifest properly? I tried to just delete that section and resulted in crashes after the device tried to rotate the app.
     
  6. sooryan

    sooryan

    Joined:
    Nov 29, 2012
    Posts:
    2
    I too have same problem here.Not finding any proper solution.I am using unity 4.2.2
    also free facbook sdk installed
     
  7. renanss

    renanss

    Joined:
    Sep 10, 2012
    Posts:
    38
    Anybody knows how to fix this?
    I'll try to look a deep more on the manifest file, but as said early, it's very easy to crash this file.
     
  8. renanss

    renanss

    Joined:
    Sep 10, 2012
    Posts:
    38
    Anyone still interested, the solution was to edit the AndroidManifest.xml of the plugin, in my case, ChartBoost.

    This is how I forced to keep my game in landscape mode:
    Code (csharp):
    1.  
    2.         <activity android:name="com.chartboost.sdk.unity.CBUnityPlayerActivity"
    3.                   android:label="@string/app_name"
    4.                   android:screenOrientation="landscape"
    5.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    6.         </activity>
    7.         <activity android:name="com.chartboost.sdk.unity.CBUnityPlayerNativeActivity"
    8.                   android:label="@string/app_name"
    9.                   android:screenOrientation="landscape"
    10.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    11.             <meta-data android:name="android.app.lib_name" android:value="unity" />
    12.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    13.         </activity>
    14.         <activity android:name="com.unity3d.player.VideoPlayer"
    15.                   android:label="@string/app_name"
    16.                   android:screenOrientation="landscape"
    17.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    18.         </activity>

    And here you can check all possbile ScreenOrientation modes:
    https://developer.android.com/guide/topics/manifest/activity-element.html#screen