using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIParentResizer : MonoBehaviour { public enum Mode { Vertical } public Mode mode; public float minHeight; public float padding = 30f; public List observedElements; private RectTransform ownRT; public void Trigger() { if (ownRT == null) { ownRT = GetComponent(); } float num = 0f; foreach (RectTransform observedElement in observedElements) { LayoutRebuilder.ForceRebuildLayoutImmediate(observedElement); num += observedElement.sizeDelta.y; } if (num < minHeight) { num = minHeight; } ownRT.sizeDelta = new Vector2(ownRT.sizeDelta.x, num + 2f * padding); } }