马上注册,加入CGJOY,让你轻松玩转CGJOY。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
图解
分辨率 1
分辨率2
分辨率3
程序:
//定义 一个基准,这个也非常重要,你默认的分辨率来定义按钮位置,【基准】,也可以自己设置。
var setScreenWidth : float = 1024;
var setScreenHeight : float = 768;
//定义缩放因子变量
var widthFactor : float;
var heightFactor : float;
//定义 位置变量,可以自己设置按钮的显示位置
var GUIWidthPosition : float;
var GUIHeightPostion : float;
function Start ()
{
//计算百分比(缩放因子)
widthFactor = Screen.width / setScreenWidth;
heightFactor = Screen.height / setScreenHeight;
}
function Update ()
{
if(Input.GetKey("escape"))
{
Application.Quit();
}
}
function OnGUI( )
{
// 这里是按钮的核心部分, 按钮位置乘以 缩放因子,大小乘以缩放因子
GUI.Button(Rect( GUIWidthPosition*widthFactor, GUIHeightPostion*heightFactor, 200*widthFactor, 50*heightFactor), “Position:”GUIWidthPosition*widthFactor+"and"+GUIHeightPostion*heightFactor);
} |