Advertisement
vjanomolee

Camera Fader script

Aug 25th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Camera Fader
  2.  
  3. var fadeOutTexture : Texture2D;
  4. var fadeSpeed = 0.3;
  5. var drawDepth = -1000;
  6. private var alpha = 1.0;
  7. private var fadeDir = -1;
  8.  
  9.  
  10. function OnGUI()
  11. {
  12.     alpha += fadeDir * fadeSpeed * Time.deltaTime;  
  13.     alpha = Mathf.Clamp01(alpha);  
  14.    
  15.     GUI.color.a = alpha;
  16.    
  17.     GUI.depth = drawDepth;
  18.    
  19.     GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
  20. }
  21.  
  22. function fadeIn(){
  23.     fadeDir = -1;  
  24. }
  25. function fadeOut(){
  26.     fadeDir = 1;    
  27. }
  28. function Start()
  29. {
  30.     alpha=1;
  31.     fadeIn();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement