横画面固定だが、ホームボタンが右でも左でも大丈夫なようにしようとしたとき、ビルドスクリプト側でこんな風に書いてました。
BatchBuild.cs
PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
PlayerSettings.allowedAutorotateToPortrait = false;
PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
PlayerSettings.allowedAutorotateToLandscapeRight = true;
PlayerSettings.allowedAutorotateToLandscapeLeft = true;
しかし何故か!縦画面ローテートが活きてしまう。何でだろう…と思ってたら実行時のメッセージにこんな表示が。
all orientations are disabled for auto-rotation. Enabling Portrait
UnityEditor.PlayerSettings:set_allowedAutorotateToPortrait(Boolean)
BatchBuild:AndroidBuild(Boolean) (at Assets/Editor/BatchBuild.cs:90)
BatchBuild:AndroidDevelopmentBuild() (at Assets/Editor/BatchBuild.cs:38)
90行目というのがちょうどPlayerSettings.allowedAutorotateToPortrait=false
を設定しようとしているところで、うーんつまり「オートローテーションで全方向disableになってるから、portraitをenableにするね!」ということか?
じゃあfalseのところをコメントアウトしたらいいのかな?と思いましたが、これも失敗。
結論としてこれでいけました。
BatchBuild.cs
PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
PlayerSettings.allowedAutorotateToLandscapeRight = true;
PlayerSettings.allowedAutorotateToLandscapeLeft = true;
PlayerSettings.allowedAutorotateToPortrait = false;
PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
…うーん、何だか腑に落ちない…