步骤:
1.设置NGUI的UIRoot适配方案,这样保证任何分辨率下高度能保证全部呈现。(高度设置为基准高度,即做UI得时候的高度)
2.贴上脚本,把需要移动和缩放的object拖入Inspector,选择移动或缩放方案。代码如下:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// 自适应类型
/// </summary>
public enum SelfAdaptionType
{
LeftPanel,
UpPanel,
DownPanel,
RightPanel
}
public class SelfAdaption_PC : MonoBehaviour {
public SelfAdaptionType adaptionType; //自适应类型
float screenWid;
float screenHei;
private float baseWidth=2000f; //基准宽
private float baseHeight