- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359
- 纳金币
- 335582
- 精华
- 0
|
var LeftGroupToTop:int=60;
var LeftGroupWidth:int=300;
var LeftGroupHeight:int=700;
var LeftGroupLabelWidth:int=30;
private var MoveDistance =LeftGroupLabelWidth-LeftGroupWidth;
private var XPosition;
private var StartPoint:float=MoveDistance;
function Update(){
//获取鼠标的x坐标位置
XPosition=Input.mousePosition.x;
if(XPosition<LeftGroupLabelWidth){
OpenLeftGroup ();
}
if(XPosition>LeftGroupWidth){
CloseLeftGroup();
}
}
function OnGUI () {
GUI.Box(Rect(100,0,100,400),XPosition.ToString());//可以去掉,调试看效果用的
GUI.Box(Rect(100,500,100,400),StartPoint.ToString());//可以去掉,调试看效果用的
//下面是组里面的内容
GUI.BeginGroup(Rect(StartPoint,LeftGroupToTop,LeftGroupWidth,LeftGroupHeight));
GUI.Box(Rect(0,0,LeftGroupWidth,LeftGroupHeight),"");
GUI.Box(Rect(LeftGroupWidth- LeftGroupLabelWidth,0,LeftGroupLabelWidth,LeftGroupHeight),"qiyechaxun");
GUI.EndGroup ();//组结束
}
//控制菜单的伸出
function OpenLeftGroup () {
if(StartPoint < 0.0) {
StartPoint +=1.0;
yield WaitForSeconds (2);
}
}
//控制菜单的收回
function CloseLeftGroup () {
if(StartPoint >MoveDistance) {
StartPoint -=0.1;
yield WaitForSeconds (5);
}
} |
|