When does canvas layout complete?

The case: We’re populating the content area of a ScrollRect dynamically when constructing a particular page in the UI - that is, we have a list. The elements of this list have different heights, depending on the amount of content in a Text component.

Timing considerations become important in two distinct cases:

  1. When navigating to this view, we render it to a RenderTexture used in a transition animation. Here, we need to wait until layout is complete before actually rendering the view.
  2. When adding a new element to the list, we’d like to scroll to the bottom so that the user sees the addition. Again, setting the normalizedVerticalPosition to zero before the layout has completed results in it scrolling almost to the end of the list, but not quite.

The following questions arise:

  1. We can request a relayout using LayoutRebuilder and/or registering a canvas element (the scroll rect) with the CanvasUpdateRegistry. But when should we use which? Are there other mechanisms we should know about?
  2. According to the documentation, canvas layout is performed before rendering, at the end of the frame, and we’ve assumed that waiting in a coroutine with WaitForEndOfFrame should be sufficient to ensure a complete layout, but that doesn’t always seem to be the case. Is there a way to get notified when layout has completed?


It’s a long time since, so I don’t I remember exactly, but I think we didn’t find any answers - probably we found some kind of workaround, but I’m not sure. We’ve moved on from Unity since then. Sorry that I can’t help…