Since we are doing UGUI change within a coroutine, try not to use
yield return null;
we talking about the anime logic modify by code, I often use “yield return null”, in my code, but today I found a strange bugs that randomly triggered by my coroutine.
“Trying to add Image for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported.”
I keep looking for the root cause and start simplify my code, at the end, it seems like it’s because the coroutine trying to apply change into the Image component more that once within a single UI update cycle. (it make senses, if you read the error message throw by editor),
so the solution is, when we handling UI component update, we should use
yield return new WaitForEndOfFrame();
this must be a reason for Unity offer you “WaitForEndOfFrame()” methods,
at least it work for me on Unity3D version 5.4.2f1.