There is a feature in my project that essentially reads the scene objects’ hierarchy (which can be altered at will by the user to create very ellaborate constructs) and creates a 2D representation of said hierarchy in a special UI window.
Every item in the scene is represented in that window by an item that is itself a layout element and a vertical layout group with a content size fitter. That gives every item the ability to contain and represent as many other items as possible, along with their own children, as the panels stretch accordingly (this bit works).
However, the “LayoutRebuilder.ForceRebuildLayoutImmediate” function does not manage to properly set all items’ stretching correctly in a single pass, probably due to the nature of multiple layout groups parented inside each other. After being called once, some items will have stretched properly, but others will not. Calling the LayoutRebuilder multiple times does fix the matter, but since the parenting in the scene can “theorethically” be infinite, I cannot set a definite amount of times to call the LayoutRebuilder after building the window.
Does anyone know of a way to force the LayoutRebuilder to run until UI objects’ rectTransform no longer change from being updated or something similar? I could have a function that runs on every item in the window, but since they can be very numerous, it would slow the program down immensely…
(this all happens in C#)
Thank you in advance!