这种效果对于有一些动画插件,比如itween就很容易实现,但是他是基于gameobject的,而这代码是基于unity自带的GUI实现的!
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#pragma strict
var windowRect = Rect (0, -50, 200 , 50);
var timetext:float=0;
function Start(){
}
function OnGUI () {
windowRect = GUI.Window (0,Rect(0,windowRect.y,Screen.width,windowRect.height), DoMyWindow, "缩进窗口");
if(Input.mousePosition.y>700){
if(timetext==0)
timetext=Time.time;
var anim = new AnimationCurve( Keyframe (0, -50), Keyframe (0.5, 10),Keyframe (0.8, -5),Keyframe (1.1, 3),Keyframe (1.6, 0));
windowRect.y=anim.Evaluate(Time.time-timetext);
}
else{
timetext=0;
if(windowRect.y>-50)
windowRect.y--;
}
}
function DoMyWindow (windowID : int) {
if(GUI.Button (Rect (10,20,100,20), "button1")){
};
if(GUI.Button (Rect (120,20,100,20), "button2")){
};
if(GUI.Button (Rect (230,20,100,20), "button3")){
};
}
function Update() {
}
|