Hi guys.
I need to make a fade-out effect for my label.
Here is my code:
using UnityEngine;
using UnityEngine.UI;
public class TweenAlpha : MonoBehaviour
{
public float Speed;
private Text Label;
private float alpha;
private Color color;
/* -------- */
void Start()
{
Label = GetComponent<Text>();
if(Label == null)
this.enabled = false;
color = Label.color;
}
/* -------- */
void Update()
{
alpha += Time.deltaTime / Speed;
color.a = alpha;
Label.color = color;
}
/* -------- */
}
For example:
Speed = 3 (Fade-in effect)
Speed = -3 (Fade-out effect).
As i said i need to make a fade-out effect,but here is my problem : the alpha value of my label becomes immediately…let’s say ‘zero’.
However, fade-in effect works fine with this script.