public void StartFade(Color screenColor, float speed, ArgumentVoid toRun) { fadeScreen.SetActive(true); screenColor.a = 0; StartCoroutine(FadeFrame(screenColor, speed, toRun)); }
IEnumerator FadeFrame(Color screenColor, float speed, ArgumentVoid toRun) { yield return new WaitForEndOfFrame(); Debug.Log(screenColor); fadeScreen.GetComponent<Image>().color = screenColor; if (screenColor.a >= 1f) { toRun(); } else { screenColor.a += Time.deltaTime; StartCoroutine(FadeFrame(screenColor, speed, toRun)); } }