16 public void Fade(
FadeAction fadeAction,Action callback,Action centerCallback=
null)
21 StartCoroutine(
FadeIn(callback));
24 StartCoroutine(
FadeOut(callback));
35 private IEnumerator
FadeIn(Action callback)
37 for (
float i = 0; i <= 1; i += Time.deltaTime)
39 _fadeRawImage.color =
new Color(0, 0, 0, i);
43 _fadeRawImage.color =
new Color(0, 0, 0, 1);
46 private IEnumerator
FadeOut(Action callback)
48 for (
float i = 1; i >= 0; i -= Time.deltaTime)
50 _fadeRawImage.color =
new Color(0, 0, 0, i);
54 _fadeRawImage.color =
new Color(0, 0, 0, 0);
57 private IEnumerator
FadeInAndOut(Action callback,Action centerCallback)
59 for (
float i = 0; i <= 1; i += Time.deltaTime)
61 _fadeRawImage.color =
new Color(0, 0, 0, i);
64 centerCallback?.Invoke();
65 yield
return new WaitForSeconds(1);
67 for (
float i = 1; i >= 0; i -= Time.deltaTime)
69 _fadeRawImage.color =
new Color(0, 0, 0, i);
72 _fadeRawImage.color =
new Color(0, 0, 0, 0);
78 for (
float i = 1; i >= 0; i -= Time.deltaTime)
80 _fadeRawImage.color =
new Color(0, 0, 0, i);
83 yield
return new WaitForSeconds(1);
85 for (
float i = 0; i <= 1; i += Time.deltaTime)
87 _fadeRawImage.color =
new Color(0, 0, 0, i);
90 _fadeRawImage.color =
new Color(0, 0, 0, 1);