Hello community!
Copied from the manual’s documentation on recalculating the Auto Layout of the UI system, by using the LayoutRebuilder.MarkLayoutForRebuild (transform as RectTransform) function:
“The rebuild will not happen
immediately, but at the end of the
current frame, just before rendering
happens.”
From this instruction only, I assume that I have to wait for the next frame, so that the current modifications in the layout’s properties will take effect and therefore to be possible to consider them in new calculations. With this assumption I have been using a yield instruction right after I have called the Rebuild function. Am I correct so far?
There is a visual side effect of using the yield coroutine, however. Given that the layout changes are applied within a number of frames by the end of each one the graphics are also calculated, the result is an animation effect of the changes. Although in my case it is not a bad contribution (rather the opposite), I was wondering on one hand, if I even approach the whole thing correctly and, on the other, what can be done if this animation effect is not desired. Is there even a way to move to the next frame, without having the graphics of the particular objects updated, until we want this to happen (in this case, after the layout changes have been applied)?
Thanks in advance for any help. Since the UI system is relatively new there are not many examples around (especially regarding run time GUI development) from which I can get ideas and solutions.