I have a container object with LayoutElement (min height 200), ContentSizeFitter(Unconstrained, Preferred Size) and a vertical layout group.
One of the children needs to have its height modified and the container object should rescale accordingly. When changing the value in editor mode, it shows fine but once running, the values change but not the visual.
timer = 0f;
rt = _buttonReceivedContainer.GetComponent<RectTransform>();
startPos = rt.sizeDelta.y;
while (timer < 1)
{
float lerp = Mathf.Lerp(startPos, 0, timer);
rt.sizeDelta = new Vector2(rt.sizeDelta.x, lerp);
timer += Time.deltaTime * speed;
Canvas.ForceUpdateCanvases();
yield return null;
}
I tried with WaitForEndOfFrame or LayoutRebuilder.ForceRebuildLayoutImmediate(rt) and the result is always same, no resizing of the container.
Luke Warm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.