64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using UnityEngine;
|
||
|
|
using TMPro;
|
||
|
|
|
||
|
|
public class IntroFadeController : MonoBehaviour, IPointerDownHandler {
|
||
|
|
[SerializeField] List<TextMeshProUGUI> text;
|
||
|
|
[SerializeField] List<Image> 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<CanvasRenderer>().SetAlpha(1.0f);
|
||
|
|
tmPro.CrossFadeAlpha(0.0f, crossFadeTime, false);
|
||
|
|
}
|
||
|
|
foreach (Image image in images) {
|
||
|
|
image.GetComponent<CanvasRenderer>().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<CanvasRenderer>().SetAlpha(0.0f);
|
||
|
|
tmPro.CrossFadeAlpha(1.0f, crossFadeTime, false);
|
||
|
|
}
|
||
|
|
foreach (Image image in images) {
|
||
|
|
image.GetComponent<CanvasRenderer>().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()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|