my fadeout in the new GUI system is not working...

this is a continuation of this question I made: making a fadeout with the new GUI in 4.6? - Unity Answers 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 :frowning:

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));