{"id":1670,"date":"2016-10-26T01:34:42","date_gmt":"2016-10-25T17:34:42","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1670"},"modified":"2016-10-26T01:46:07","modified_gmt":"2016-10-25T17:46:07","slug":"trying-to-add-image-for-graphic-rebuild-while-we-are-already-inside-a-graphic-rebuild-loop-this-is-not-supported","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/1670\/","title":{"rendered":"Trying to add Image for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported"},"content":{"rendered":"<p>Since we are doing UGUI\u00a0change within a coroutine, try not to use<\/p>\n<pre class=\"brush:csharp\">yield return null;<\/pre>\n<p>we talking about the anime logic modify by code, I\u00a0often use &#8220;yield return null&#8221;, in my code, but today I found a strange bugs that randomly triggered by my coroutine.<\/p>\n<p>&#8220;<span style=\"color: #ff0000;\">Trying to add Image for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported.<\/span>&#8221;<\/p>\n<p>I keep looking for the root cause and start simplify my code,\u00a0at the end, it seems like it&#8217;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),<\/p>\n<p>so the solution is, when we handling UI component update, we should use<\/p>\n<pre class=\"brush:csharp\">yield return new WaitForEndOfFrame();<\/pre>\n<p>this must be a reason for Unity offer you &#8220;WaitForEndOfFrame()&#8221; methods,<\/p>\n<p>at least it work for me on Unity3D version 5.4.2f1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since we are doing UGUI\u00a0change within a coroutine, &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[43],"class_list":["post-1670","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1670"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1670\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}