Search Unity

Please give some advice about ScreenOrientation

Discussion in 'Scripting' started by Harardin, Dec 2, 2016.

  1. Harardin

    Harardin

    Joined:
    Aug 5, 2015
    Posts:
    58
    Hello everyone.

    I don’t have much of experience in working with Android and iOS devices.

    So I’am asking for advice

    If I want in some statement left Screen oriented only Portrait should it be like this?
    Code (CSharp):
    1.     void Update () {
    2.         if ("this true")
    3.         {
    4.             Screen.autorotateToPortrait = true;
    5.             Screen.autorotateToLandscapeLeft = false;
    6.             Screen.autorotateToLandscapeRight = false;
    7.             Screen.autorotateToPortraitUpsideDown = false;
    8.             Screen.orientation = ScreenOrientation.Portrait;
    9.         }
    10.         else if ("another condition when I want it to be left oriented and portrait")
    11.         {
    12.             Screen.autorotateToPortrait = true;
    13.             Screen.autorotateToLandscapeLeft = true;
    14.             Screen.autorotateToLandscapeRight = false;
    15.             Screen.autorotateToPortraitUpsideDown = false;
    16.             Screen.orientation = ScreenOrientation.AutoRotation;
    17.         }
    18.     }
    Will this work?
    Sorry if this is simple question but testing it via compilation is longer then ask some one.
    Thanks.
     
  2. Harardin

    Harardin

    Joined:
    Aug 5, 2015
    Posts:
    58
    Yeap it will work.