纳金网
标题:
[NGUI]NGUI宽度适应
[打印本页]
作者:
驰骋的风
时间:
2013-3-2 10:04
标题:
[NGUI]NGUI宽度适应
using UnityEngine;
using System.Collections;
public class UIRootExtend : MonoBehaviour {
public int manualWidth = 640;
private UIRoot _UIRoot;
void Awake()
{
_UIRoot = this.GetComponent<UIRoot>();
}
void Start ()
{
if(Screen.width < Screen.height)
_UIRoot.manualHeight = System.Convert.ToInt32( System.Convert.ToSingle( Screen.height) / System.Convert.ToSingle( Screen.width) * System.Convert.ToSingle( manualWidth) );
}
}
只需要把这个插件Add到UIRoot就可以了
当屏幕宽度小于屏幕高度的时候,根据manualWidth调整UIRoot的manualHeight
原作者:vinson 转载于UNITY3D圣典
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5