投稿

10月, 2012の投稿を表示しています

[Unity]NGUIで画面サイズに合わせる(NGUI2.2.2対応版)

2013/5/4 追記 : スクリプトは [Unity]NGUIで画面サイズに合わせる(NGUI2.3.0対応版) が最新です。 以前 [Unity]NGUIで画面サイズに合わせる(その2) で書いたスクリプトが、NGUI のバージョンアップによる機能追加との兼ね合いで正しく動かなくなっていたので、その暫定対応版です。 NGUI 2.2.2 : http://www.tasharen.com/forum/index.php?topic=11.msg9404#msg9404  に - NEW: You can now specify a minimum and maximum height on UIRoot. とある通り、UIRoot に minimumHeight と maximumHeight が追加されました。ソースのコメントより If the screen height goes below this value, it will be as if 'automatic' is turned off with the 'manualHeight' set to this value. とのことで、画面サイズが minimunHeight を下回った場合に画面サイズに合わせて縮小するのを諦めてはみ出させたり、maximumHeight を上回った場合に拡大するのをやめて余白を作るための機能のようです。 この条件下で以前のスクリプトが正しく動かなくなっていたので、取り急ぎこの機能追加を実質無視するような方向での対応を加えたものが以下です。 using UnityEngine; using System.Collections; [ExecuteInEditMode] public class NGUIUtilScalableUIRoot : MonoBehaviour { public int manualWidth = 1280; public int manualHeight = 720; UIRoot uiRoot_; void Awake() { uiRoot_ = GetComponent<UIRoo