//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);
}
}