- Home /
Help with destroying guiRect?
This is a part of a script that when the boolean "fadeNow" is true, it draws a black square on the screen to add a fade out effect. When the boolean "fadeAgain" is true, it must draw again a square but whith the reversed effect, so as the black screen to turn back to normal. The problem is that the old black square remains in the screen, What can I do?
 var fadeTexture : Texture2D;
 var fadeSpeed = 0.2;
 var drawDepth = -1000;
 
 private var alpha = 1.0;
 private var alpha2 = 0.0;
 private var fadeDir = -1;
 private var fadeNow : boolean;
 private var fadeAgain : boolean;
 
 
 function OnGUI(){
     if(fadeNow)
     {
         alpha2 -= fadeDir * fadeSpeed * Time.deltaTime;
         alpha2 = Mathf.Clamp01(alpha2);
      
         GUI.color.a = alpha2;
      
         GUI.depth = drawDepth;
      
         GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
     }
     if(fadeAgain)
     {
         //Destroy() I tried to destroy the old square........................
         alpha += fadeDir * fadeSpeed * Time.deltaTime;
         alpha = Mathf.Clamp01(alpha);
  
         GUI.color.a = alpha;
  
         GUI.depth = drawDepth;
  
         GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
     }
 
               Comment
              
 
               
              Hey What if you put fadeNow = false at the end of the if-statement
Your answer
 
 
             Follow this Question
Related Questions
Fill rectangle from bottom to top 1 Answer
Fade in/out continously 1 Answer
Movie GUI Texture Alpha? 1 Answer
My GUI IS Bugging Out. Can Anyone Help? 0 Answers
gui draw rexture problem 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                