您的位置:首页 > 产品设计 > UI/UE

NGUI_自适应(适应多屏幕分辨率)

2014-11-13 14:37 477 查看
//create UI

set UIRoot(Script):

Scalling: FixedSizeOnMobiles

Manual Height:800

Minimuam Height:800

Maximum Height:1536

//create Panel

Add UIStretch(Script) and set:

Style:FitInternalKeepingRatio

Initial Sizw:x:1280 y:800

//create Widget

set anchors 

Type:Unified

   Target:Panel

//SetTransformToFitAllScreen

//在UIRoot 上添加脚本:

public bool _ifChangePosition=true;

public bool _ifChangeScale=true;

void Start()

{

//自适应屏幕分辨率

if(_ifChangePosition)

{

transform.localPosition=new Vector3(transform.localPosition*Screen.width/902,transform.localPosition*Screen.height/504,transfrom.localPositon.z);

}

if(_ifChangeScale)

{

transform.localScale=new Vector3(transform.localScale*Screen.width/902,transform.localScale*Screen.height/504,transform.localScale.z);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ngui