using System.Collections; using System.Collections.Generic; using UnityEngine.EventSystems; using UnityEngine.UI; using UnityEngine; using TMPro; public class IntroFadeController : MonoBehaviour, IPointerDownHandler { [SerializeField] List text; [SerializeField] List images; [SerializeField] float crossFadeTime = 1.0f; [SerializeField] float waitTime = 1.5f; [HideInInspector] bool readyToTurnOff = false; [HideInInspector] bool turningOff = false; [HideInInspector] public bool turnedOff = false; public void OnPointerDown(PointerEventData eventData) { if (readyToTurnOff && !turningOff) { foreach (TextMeshProUGUI tmPro in text) { tmPro.GetComponent().SetAlpha(1.0f); tmPro.CrossFadeAlpha(0.0f, crossFadeTime, false); } foreach (Image image in images) { image.GetComponent().SetAlpha(1.0f); image.CrossFadeAlpha(0.0f, crossFadeTime, false); } turningOff = true; StartCoroutine("DoNextWait"); } } // Start is called before the first frame update void Awake() { readyToTurnOff = false; foreach (TextMeshProUGUI tmPro in text) { tmPro.GetComponent().SetAlpha(0.0f); tmPro.CrossFadeAlpha(1.0f, crossFadeTime, false); } foreach (Image image in images) { image.GetComponent().SetAlpha(0.0f); image.CrossFadeAlpha(1.0f, crossFadeTime, false); } StartCoroutine("DoWait"); } IEnumerator DoWait() { yield return new WaitForSeconds(waitTime); readyToTurnOff = true; } IEnumerator DoNextWait() { yield return new WaitForSeconds(crossFadeTime); turnedOff = true; } // Update is called once per frame void Update() { } }