Hello, I’ve been doing research on how to write a script to fade my UI Text i have in a Unity Scene. However, everything i find is related to the old Unity . If someone could help me figure out how to write a new script for UI or point me in a direction that would be great! Here is an old GUI text fade script i found while following tutorials, its irrelevant now i assume with unity 5.x
using UnityEngine;
using System.Collections;
public class UIfadeOutText : MonoBehaviour
{
const float period = 4.0f;
void Update ()
{
if(Time.time > period)
{
Destroy(gameObject);
}
Color colorOfObject = GetComponent<GUIText>().material.color;
float prop = (Time.time / period);
colorOfObject.a = Mathf.Lerp(1, 0, prop);
GetComponent<GUIText>().material.color = colorOfObject;
}
}