-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcameraFade.cs
56 lines (38 loc) · 950 Bytes
/
cameraFade.cs
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
using UnityEngine;
using System.Collections;
public class cameraFade : MonoBehaviour
{
public Texture2D fadeOutTexture;
public float fadeSpeed = 0.3f;
public int drawDepth = -1000;
private float alpha = 1.0f;
private int fadeDir = -1;
private Color fadeColor = GUI.color;
// Use this for initialization
void Start ()
{
alpha=1.0f;
fadeIn();
}
// Update is called once per frame
void Update ()
{
}
void OnGUI(){
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
fadeColor.a = alpha;
GUI.color = fadeColor;
GUI.depth = drawDepth;
GUI.DrawTexture(new Rect(0, 0, Screen.width+10, Screen.height), fadeOutTexture);
}
void fadeIn(){
fadeDir = -1;
Debug.Log("fading in");
}
//--------------------------------------------------------------------
void fadeOut(){
fadeDir = 1;
Debug.Log("fading out");
}
}