-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFadeIn.cs
35 lines (31 loc) · 950 Bytes
/
FadeIn.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
using UnityEngine;
using System.Collections;
public class FadeIn : MonoBehaviour
{
public Texture2D fadeTexture;
public float fadeSpeed = 0.2f;
public int drawDepth = -1000;
private float alpha = 1.0f;
private int fadeDir = -1;
bool done = false;
void OnGUI()
{
if (!done)
{
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
Color temp = GUI.color;
if (PlayerPrefs.GetInt("FinishedGame") == 1) temp = Color.black;
if (PlayerPrefs.GetInt("FinishedGame") == 2) alpha = 0;
temp.a = alpha;
GUI.color = temp;
GUI.depth = drawDepth;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeTexture);
if (alpha == 0)
{
done = true;
PlayerPrefs.SetInt("FinishedGame", 0);
}
}
}
}