「Unity/端末の向き」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→端末の向き) |
(→端末の向き) |
||
| 行16: | 行16: | ||
+ allowedAutorotateToLandscapeRight: 0 | + allowedAutorotateToLandscapeRight: 0 | ||
+ allowedAutorotateToLandscapeLeft: 0 | + allowedAutorotateToLandscapeLeft: 0 | ||
| + | |||
| + | ==端末向き== | ||
| + | <pre> | ||
| + | Screen.orientation; // 現在の向き | ||
| + | ScreenOrientation.LandscapeLeft; // 横左 | ||
| + | ScreenOrientation.LandscapeRight; // 横右 | ||
| + | ScreenOrientation.Portrait; // 縦 | ||
| + | </pre> | ||
| + | |||
| + | ==端末の向き許可設定== | ||
| + | falseにすると禁止となる | ||
| + | <pre> | ||
| + | // 縦 | ||
| + | Screen.autorotateToPortrait = true; | ||
| + | // 左 | ||
| + | Screen.autorotateToLandscapeLeft = true; | ||
| + | // 右 | ||
| + | Screen.autorotateToLandscapeRight = true; | ||
| + | // 上下反転 | ||
| + | Screen.autorotateToPortraitUpsideDown = true; | ||
| + | </pre> | ||
| + | https://qiita.com/satotin/items/2009788da11805a4a9cf | ||
2019年9月24日 (火) 02:13時点における版
端末の向き
File/BuildSettingsからPlayerSettingsボタンを押し "Resolution and Presentation"のorientationを変更する
- portrait:縦
- landscape:横
縦だけにすると、androidにおいて、インストール端末から、テレビやウェアラブル(時計)が除外される。
↓縦のみにした時の設定ファイル変更 ProjectSettings/ProjectSettings.asset
allowedAutorotateToPortrait: 1 - allowedAutorotateToPortraitUpsideDown: 1 - allowedAutorotateToLandscapeRight: 1 - allowedAutorotateToLandscapeLeft: 1 + allowedAutorotateToPortraitUpsideDown: 0 + allowedAutorotateToLandscapeRight: 0 + allowedAutorotateToLandscapeLeft: 0
端末向き
Screen.orientation; // 現在の向き ScreenOrientation.LandscapeLeft; // 横左 ScreenOrientation.LandscapeRight; // 横右 ScreenOrientation.Portrait; // 縦
端末の向き許可設定
falseにすると禁止となる
// 縦 Screen.autorotateToPortrait = true; // 左 Screen.autorotateToLandscapeLeft = true; // 右 Screen.autorotateToLandscapeRight = true; // 上下反転 Screen.autorotateToPortraitUpsideDown = true;
