Question by
shapirog · May 14, 2016 at 04:13 AM ·
canvasienumeratorfade
UI Canvas elements stutter during fade
Hello, I am using IEnumerator to fade off UI Canvas items. For example to fade a menu off, or to have a white flash to transition back to the menu when the player dies. However the fade stutters a lot and isn't smooth at all. Here's my code:
IEnumerator fadeOff (CanvasGroup canvasGroup) {
while (canvasGroup.alpha > 0.0f) {
canvasGroup.alpha -= Time.deltaTime * 10.0f;
yield return null;
}
}
Then for example when I want to hide the menu I use:
StartCoroutine (fadeOff(menuCanvas));
Is there a reason the fade stutters? Or should I be using something other than IEnumerator?
Thanks in advance!
Comment