Android, iPhoneなどで動かす場合には、端末の方向を考慮してGUIなどを構成する必要があります。
その場合、あらかじめ向きを固定してしまうか、画面の回転を検出して補正を行いましょう。
画面の向きを固定する
メニューの Build Settings > Player Settings と選択し、インスペクターでOrientationの項目を見ます。

- Portrait : 縦向き
- Portrait Upside Down:縦向き(上下逆)
- Landscape Right:横向き(左側面が下)
- Landscape Left:横向き(右側面が上)
- Auto Rotation:端末の向きに合わせて自動回転
Auto Rotation以外のどれかを選択すれば、表示方向を固定にできます。
画面の向きの変更を検出する
縦横両対応のゲームを作りたいなら、画面の向きの変更を検出しなければなりません。 Unityには検出用のイベントなどは無いようなので、スクリプトで検出しましょう。
deviceOrientationを使う
InputクラスのdeviceOrientationを参照すれば、現在の端末の向きが分かります。
http://docs.unity3d.com/ja/current/ScriptReference/Input-deviceOrientation.html http://docs.unity3d.com/ja/current/ScriptReference/DeviceOrientation.html
Screen.width, Screen.heightを使う
deviceOrientationでUNKNOWNやFace UPが返ってくる場合、ディスプレイのサイズで判定しましょう。
width > height なら横向き、逆なら縦向きで。
以下、deviceOrientaionも含めて判定する際のサンプルコードです。
public class DeviceOrientationDetector: MonoBehaviour {
// 直前のディスプレイ向き
DeviceOrientation PrevOrientation;
// 端末の向きを取得するメソッド
DeviceOrientation getOrientation() {
DeviceOrientation result = Input.deviceOrientation;
// Unkownならピクセル数から判断
if (result == DeviceOrientation.Unknown)
{
if (Screen.width < Screen.height)
{
result = DeviceOrientation.Portrait;
}
else
{
result = DeviceOrientation.LandscapeLeft;
}
}
return result;
}
void Start () {
PrevOrientation = getOrientation();
}
void Update () {
DeviceOrientation currentOrientation = getOrientation();
if (PrevOrientation != currentOrientation)
{
// 画面の向きが変わった場合の処理
PrevOrientation = currentOrientation;
}
}