Trying to add Image for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported

Trying to add Image for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported

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.

One comment

發佈回覆給「liang」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料