Skip to content

Instantly share code, notes, and snippets.

@st0326s
Created January 17, 2017 03:49
Show Gist options
  • Save st0326s/7db81811024a4164358d6f0dd3398792 to your computer and use it in GitHub Desktop.
Save st0326s/7db81811024a4164358d6f0dd3398792 to your computer and use it in GitHub Desktop.
Unityからスマホ画面の向きの固定・解除(iOS・Android共通) ref: http://qiita.com/satotin/items/2009788da11805a4a9cf
switch (Screen.orientation) {
// 縦画面のとき
case ScreenOrientation.Portrait:
// 左回転して左向きの横画面にする
Screen.orientation = ScreenOrientation.LandscapeLeft;
break;
// 上下反転の縦画面のとき
case ScreenOrientation.PortraitUpsideDown:
// 右回転して左向きの横画面にする
Screen.orientation = ScreenOrientation.LandscapeRight;
break;
}
// 縦
Screen.autorotateToPortrait = true;
// 左
Screen.autorotateToLandscapeLeft = true;
// 右
Screen.autorotateToLandscapeRight = true;
// 上下反転
Screen.autorotateToPortraitUpsideDown = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment