I attempted to make a pingponging colored text for my splash screen. I attempted to just change the alpha value and my color turned black on run-time. When attempting to assign a color in the function, it turned white instead. Can you guys please tell me what I'm doing wrong and how I should set the color properly?
using UnityEngine;
using UnityEngine.UI;
public class LerpAlpha : MonoBehaviour {
public float duration;
float alpha;
Text colorText;
Color textColor;
void LerpAlphaText()
{
float lerp = Mathf.PingPong(Time.time, duration) / duration;
alpha = Mathf.Lerp(0.0f, 1.0f, Mathf.SmoothStep(0.0f, 1.0f, lerp));
textColor.a = alpha;
///Also tried textColor = new Color(113, 75, 2, alpha); resulting in
///the white text
colorText.color = textColor;
}
void Start()
{
colorText = GetComponent<Text>();
}
void Update ()
{
LerpAlphaText();
}
}