- Home /
my fadeout in the new GUI system is not working...
this is a continuation of this question I made: http://answers.unity3d.com/questions/782054/making-a-fadeout-with-the-new-gui-in-46.html since for some reason I can't post in that question anymore.
Anyway, I thought of making a fadeout transition with the new GUI system by controlling the alpha of a black image component in a canvas but it's not working, my screen flickers for some reason. I'm using this code in that canvas:
  using UnityEngine;
     using System.Collections;
     using UnityEngine.UI;
     
     public class FadeOut : MonoBehaviour {
     
         private Image negro;
         public bool hacerFadeout = false;
         public float alfa;
     
     
     
         void Awake(){
     
             negro = GetComponent<Image> ();
             
         }
     
     
     
         
     
         void Update()
         {
     
             if (hacerFadeout) {
                             alfa = Mathf.Lerp (0f, 1.0f, 10f*Time.deltaTime);
                             negro.color = new Color (1.0f, 0.0f, 0.0f,alfa);
                     }
             }
     
     }
the canvas is red just to test it and I put the "hacerfadeout" variable as true manually in the inspector, again, just to test it... and when I do that, my canvas goes crazy and starts flickering!
Since my "alfa" variable is public, I can see what's going on: for some reason my Lerp function goes crazy: the values of the "alfa" variable go from 0.06 to 0.1 in a erratic manner.... what's going on?? thanks in advance :(
Answer by el-RERS · Aug 31, 2014 at 05:14 AM
Okay never mind guys, I figured this thing out, turns out I had to erase the "alfa" variable and put the initial color of my image in the "from" of the Lerp function! something like this:
negro.color = new Color (1.0f, 0.0f, 0.0f,Mathf.Lerp (negro.color.a, 1.0f, 10f*Time.deltaTime));
THANK YOU SO MUCH TO ALL!!
Your answer
 
 
             Follow this Question
Related Questions
On Click paramaters disappear from button prefab? 5 Answers
How do I make it so two players can control individual input on a canvas in unity 4.6 1 Answer
Unity 4.6 adding a Canvas Text onto a gameobject prefab?? -1 Answers
How to make slider load variable on start 1 Answer
Use Unity UI For 2D Games Or Custom Objects Instead? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                