Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float fadeSpeed = 1.5f; // Speed that the screen fades to and from white.
- private bool sceneStarting = true; // Whether or not the scene is still fading in.
- public Color transparent;
- void Awake()
- {
- // Set the texture so that it is the the size of the screen and covers it.
- GetComponent<GUITexture>().pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
- transparent = Color.black;
- transparent.a = 0f;
- }
- void Update()
- {
- // If the scene is starting...
- if (sceneStarting)
- // ... call the StartScene function.
- StartScene();
- }
- void FadeToClear()
- {
- // Lerp the colour of the texture between itself and transparent.
- GetComponent<GUITexture>().color = Color.Lerp(GetComponent<GUITexture>().color, transparent, fadeSpeed * Time.deltaTime);
- }
- public void FadeToWhite()
- {
- // Lerp the colour of the texture between itself and white.
- GetComponent<GUITexture>().color = Color.Lerp(GetComponent<GUITexture>().color, Color.black, fadeSpeed * Time.deltaTime);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement