I am trying to fade in some text, fade it out, replace it, and fade in again. Unfortunately, it doesn’t fade out all the way, and then doesn’t attempt to fade in at all.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class fadeIn : MonoBehaviour {
public bool showWelcome = false;
void Start () {
gameObject.GetComponent<UnityEngine.UI.Text>().CrossFadeAlpha(0f, 0f, false);
}
void Update ()
{
if (showWelcome == true)
{
textIn();
StartCoroutine(text2());
}
}
void textIn ()
{
gameObject.GetComponent<UnityEngine.UI.Text>().CrossFadeAlpha(1f, 1f, false);
}
void textOut ()
{
gameObject.GetComponent<UnityEngine.UI.Text>().CrossFadeAlpha(0f, 1f, false);
}
IEnumerator text2()
{
yield return new WaitForSeconds(5);
textOut();
yield return new WaitForSeconds(5);
gameObject.GetComponent<UnityEngine.UI.Text>().text = ("This is a custom UI for Windows Desktop");
textIn();
}
}