- Home /
How to edit a fade screen script to change color on demand?
Here is the Fade Screen code; I want to be able to change the color of the fade screen to be a different color depending on how the script was triggered, by dying(RED) or entering a secret room(BLUE).
function Update () {
 }
 
 public var fadeOutTexture : Texture2D;
 public var fadeSpeed = 2.0;
 var drawDepth = -1000;
 var alphaWait : boolean = true;
 
 private var alpha = 1.0;
 private var fadeDir = -1;
 
 function OnGUI(){
 
    if(alphaWait == false) {
    
     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), fadeOutTexture);
 }
 
 function fadeIn(){
      GameObject.Find("First Person Controller").GetComponent(CharacterController).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(FPSWalkerEnhanced).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(CrouchHeight).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(CharacterMotor).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
     GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = false;
     yield WaitForSeconds(2);
     alphaWait = false;
     fadeDir = -1;
     GameObject.Find("First Person Controller").GetComponent(CharacterController).enabled = true;
     GameObject.Find("First Person Controller").GetComponent(FPSWalkerEnhanced).enabled = true;
     GameObject.Find("First Person Controller").GetComponent(CrouchHeight).enabled = true;
     GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = true;
     GameObject.Find("First Person Controller").GetComponent(CharacterMotor).enabled = true;
     GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true;
     GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = true;  
 }
 
 function fadeOut(){
     GameObject.Find("First Person Controller").GetComponent(CharacterController).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(FPSWalkerEnhanced).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(CrouchHeight).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(CharacterMotor).enabled = false;
     GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
     GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = false;
     fadeDir = 1;   
 }
 
 function Start(){    
     
     alpha=1;
     fadeIn();
 }
Here is a piece of code from my main coding attached to my player
 function OnTriggerEnter (other : Collider)
 {
     var fade = GameObject.FindWithTag("Player");
     if(other.tag == "Death")
     {
         fade.GetComponent(FadeOut).fadeOut();
         yield WaitForSeconds(2);
         Application.LoadLevel(1); //death screen
         fade.GetComponent(FadeOut).fadeIn();
         GameObject.Find("First Person Controller").GetComponent(CharacterController).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(FPSWalkerEnhanced).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(CrouchHeight).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(CharacterMotor).enabled = true;
         GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true;
         GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = true;
     }
               Comment
              
 
               
              Answer by ALEGOMan · Dec 16, 2014 at 02:13 PM
That only works for fading in a new scene, I want it to know what scene is is going to load before it fades out in a different color
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                