29 lines
No EOL
992 B
C#
29 lines
No EOL
992 B
C#
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<VerticalLayoutGroup>();
|
|
if (layout == null)
|
|
layout = gameObject.AddComponent<VerticalLayoutGroup>();
|
|
|
|
layout.childForceExpandHeight = false;
|
|
layout.childForceExpandWidth = true;
|
|
layout.childControlHeight = true;
|
|
layout.childControlWidth = true;
|
|
layout.spacing = 10;
|
|
|
|
var fitter = gameObject.GetComponent<ContentSizeFitter>();
|
|
if (fitter == null)
|
|
fitter = gameObject.AddComponent<ContentSizeFitter>();
|
|
|
|
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
|
fitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
|
|
}
|
|
}
|
|
} |