NGUIで縦持ち解像度対応
以下のような縦持ちゲームの(よくある黒帯)解像度対応をNGUIで行うためには
http://schoolgirlstrikers.jp/camp1407/ の壁紙使用
- iPhone4(640x960)
-
iPhone5(640x1136)
- 解像度640x960の壁紙をUISpriteとしてUIPanel下に追加
(解像度が調整されていることを確認するため) - UIRootのScalingStyleをFixedSizeに変更
- 以下のスクリプトをUIRootにアタッチする
using UnityEngine;
[ExecuteInEditMode]
public class UIRootVerticalAdjuster : MonoBehaviour {
public int manualWidth = 640;
void Update () {
UIRoot root = this.GetComponent<UIRoot> ();
root.manualHeight = Mathf.FloorToInt (Screen.height * this.manualWidth / Screen.width);
}
} - UIRoot下のCameraのBackgroundをRGB000に変更
- Gameビューで解像度を切り替えて試してみる
補足として
- manualWidthは基準となる横幅を設定する
- Updateで調整している(&ExecuteInEditMode)のはUnityEditor上で確認するためなので、実運用時は要修正