-
Notifications
You must be signed in to change notification settings - Fork 14
RebuildingUI
Texts and images are built during conversion, when the resolution of the screen changes, and when the content changes.
During conversion, the HierarchyConversionSystem
recurses through the entire hierarchy of the Canvas and builds each
image and text element. The vertices and indices generated are placed in a buffer for the mesh to be built.
When the screen resolution changes, all canvases have to be rebuilt. Like conversion, the BuildRenderHierarchySystem
collects different types of UI elements, such as images, dynamic texts, and static text.
Dynamic text is any text that changes, while static text is any text that does not change throughout its life time. You can think of Static Text as labels which describe the information being presented but does not change. Dynamic text can be anything like dialogue changes, a spedometer, an FPS counter, etc.
When we rebuild the canvas during runtime, we want to utilize multiple threads to build all static text and images first. Because, static content never needs to change, we can write directly to the VertexBuffer without having to change the meshes' indices.
After we finish building all of the static content, we build the dynamic content. This is done on a single thread because the entities are sorted to ensure that the elements in a lower submeshed are built first and elements in a higher submesh are built last. This ensures that submeshes are properly combined together when the mesh is built at its final step.
All text and images are built after the Canvas has been rescaled and after all the elements have been reanchored.