-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFadeInOut.js
58 lines (41 loc) · 1.4 KB
/
FadeInOut.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// FadeInOut
//
//--------------------------------------------------------------------
// Public parameters
//--------------------------------------------------------------------
public var fadeOutTexture : Texture2D;
public var fadeSpeed = 0.3;
//var canFade : boolean = false;
var drawDepth = -1000;
//--------------------------------------------------------------------
// Private variables
//--------------------------------------------------------------------
private var alpha = 0.0;
private var fadeDir = -1;
//private var fadeDirHalf = .5;
//--------------------------------------------------------------------
// Runtime functions
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function OnGUI(){
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color.a = alpha;
GUI.depth = drawDepth;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
//--------------------------------------------------------------------
function fadeIn(){
fadeDir = -1;
}
//--------------------------------------------------------------------
function fadeOut(){
fadeDir = 1;
}
function Start(){
alpha=1;
fadeIn();
}
function fadeOutHalf(){
fadeDir = .5;
}