private IEnumerator _FadeOut(TextFadeCallback callBackOnEnd) { float currentTime = 0f; while (currentTime < FadeOutTime) { float alpha = Mathf.Lerp(1f, 0f, currentTime / FadeOutTime); _text.color = new Color(_text.color.r, _text.color.g, _text.color.b, alpha); currentTime += Time.deltaTime; yield return(null); } if (callBackOnEnd != null) { callBackOnEnd.Invoke(); } _text.enabled = false; }
public void FadeOut(TextFadeCallback callbackOnEnd = null) { StartCoroutine(_FadeOut(callbackOnEnd)); }