Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NewBehaviourScript : MonoBehaviour {
  5.  
  6.     public Texture2D fadeOutTexture;
  7.     public float fadeSpeed = 0.3f;
  8.     private const int DRAW_DEPTH = -1000;
  9.     private float alpha = 1.0f;
  10.     private int fadeDir = -1;
  11.  
  12.      void OnGUI()
  13.     {
  14.          alpha += fadeDir * fadeSpeed * Time.deltaTime;
  15.          alpha = Mathf.Clamp01(alpha);
  16.  
  17.          GUI.color = new Color()
  18.          {
  19.              a = alpha
  20.          };
  21.  
  22.          GUI.depth = DRAW_DEPTH;
  23.  
  24.          GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
  25.  
  26.     }
  27.  
  28.     public void FadeIn()
  29.      {
  30.          fadeDir = -1;
  31.      }
  32.  
  33.     public void FadeOut()
  34.     {
  35.         fadeDir = 1;
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement