private IEnumerator FadeOut() { float value = 1; OnFadeOutStart.Invoke(); while (value > 0) { value -= 0.05f; canvasGroup.alpha = value; yield return(new WaitForEndOfFrame()); } OnFadeOutEnd.Invoke(); FadeOutComplete(); gameObject.SetActive(false); }
IEnumerator FadeOut() { OnFadeOutStart?.Invoke(eventData); image.enabled = true; image.color = Color.black; timer = time; float process; while (timer >= 0) { timer -= Time.deltaTime; process = timer / time; image.color = new Color(0, 0, 0, process); yield return(0); } image.enabled = false; timer = -0f; OnFadeOutDone?.Invoke(eventData); }