using UnityEngine; using UnityEngine.UI; namespace ShiroginSDK.Runtime.Modules.IAP.Scripts.UI.Helpers { [RequireComponent(typeof(RectTransform))] public class AutoExpandLayout : MonoBehaviour { private void Awake() { var layout = gameObject.GetComponent(); if (layout == null) layout = gameObject.AddComponent(); layout.childForceExpandHeight = false; layout.childForceExpandWidth = true; layout.childControlHeight = true; layout.childControlWidth = true; layout.spacing = 10; var fitter = gameObject.GetComponent(); if (fitter == null) fitter = gameObject.AddComponent(); fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; fitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; } } }