-
Notifications
You must be signed in to change notification settings - Fork 0
/
FadeInOut.cs
66 lines (56 loc) · 1.49 KB
/
FadeInOut.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
56
57
58
59
60
61
62
63
64
65
66
using UnityEngine;
using System.Collections;
public class FadeInOut : MonoBehaviour
{
static float timeToFadeIn;
static float timeToFadeOut;
public static bool fadeIn = false;
public static bool fadeOut = false;
public float timeToFade;
public Texture fade;
// Use this for initialization
void Start ()
{
fadeIn = true;
fadeOut = false;
timeToFadeIn = 0;
timeToFadeOut = 0;
}
// Update is called once per frame
void Update ()
{
if (fadeIn == true)
timeToFadeIn += Time.deltaTime;
if (fadeOut == true)
timeToFadeOut += Time.deltaTime;
//print ("Fade In: "+fadeIn+" --- Fade Out: "+fadeOut+" --- Time To Fade In: "+timeToFadeIn+" --- Time To Fade Out: "+timeToFadeOut);
}
void OnGUI ()
{
if (fadeIn == true)
{
GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, 1 -timeToFadeIn/timeToFade);
GUI.DrawTexture (new Rect(0,0,Screen.width,Screen.height),fade);
}else if (fadeOut == true)
{
GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, timeToFadeOut/timeToFade);
GUI.DrawTexture (new Rect(0,0,Screen.width,Screen.height),fade);
}
if (GUI.color.a <= 0)
{
fadeIn = false;
if (Menu.numLevel == -1)
SplashScreen.countFadeOut = true;
}else if (fadeOut && GUI.color.a >= timeToFade)
{
fadeOut = false;
timeToFadeIn = 0;
timeToFadeOut = 0;
if (Menu.numLevel > 0 && Player.passedLevel == false)
{
Application.LoadLevel("Job"+(Menu.numLevel +1));
Player.passedLevel = true;
}
}
}
}