unity in ContentSizeFitter refresh problem is not timely

ContentSizeFitter, width and height adaptive script will adapt to the width and height at the time of the next frame. If you want to take effect immediately, you can call

LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);

  rectTransform here is the current RectTransForm object.

Another problem here is that if it is ContentSizeFitter nest, you need to refresh every RectTransForm

foreach (all child objects have ContentSizeFitter)
{
   LayoutRebuilder.ForceRebuildLayoutImmediate (rectTransform sub-object);
}

  

Guess you like

Origin www.cnblogs.com/zhoushiya/p/12209939.html