Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class NewBehaviourScript : MonoBehaviour {
- public Texture2D fadeOutTexture;
- public float fadeSpeed = 0.3f;
- private const int DRAW_DEPTH = -1000;
- private float alpha = 1.0f;
- private int fadeDir = -1;
- void OnGUI()
- {
- alpha += fadeDir * fadeSpeed * Time.deltaTime;
- alpha = Mathf.Clamp01(alpha);
- GUI.color = new Color()
- {
- a = alpha
- };
- GUI.depth = DRAW_DEPTH;
- GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
- }
- public void FadeIn()
- {
- fadeDir = -1;
- }
- public void FadeOut()
- {
- fadeDir = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement