I want to make the FadePanel image to fade from 0 to 128, but its not really working
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PanelTransition : MonoBehaviour {
public Image FadePanel;
void Update ()
{
FadePanel.color.a = Mathf.Lerp(0,128,Time.time);
}
}
So, the answer above links to a solution from 2012. The author wants to know how you do it in the new 4.6 GUI library, which is only recently available. Take a look at UI.Graphic.CrossFadeAlpha found here.
Say you have a UI.Text object named text, and you want it to fade out over the next half second:
text.CrossFadeAlpha(0, .5f, false);
I hope this helps someone else. Sorry, I donāt understand what the false (ignore timestamp) does. The docs page for it is missing.
Basically, stay away from Time.time. that value is equal to the number of seconds that passed since you started the program.
Thereās 2 options available to achieve what you want. either you use an incrementing value (that goes from 0 to 1 over time) instead of Time.time. Something like :
The effects are slightly different, The first one will be more linear, as for the second one, it will be more āquadraticāā¦ it depends on which you prefer.