using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Scrollable : MonoBehaviour { public const float size = 35f; void Start() { Reload(); } public void Reload() { var sizeY = (transform.childCount-1) * (transform.GetChild(0).GetComponent().sizeDelta.y + GetComponent().spacing); Debug.Log(transform.childCount + "sizeY: "+sizeY); GetComponent().offsetMax = Vector2.zero; GetComponent().offsetMin = new Vector2(GetComponent().offsetMin.x, transform.parent.GetComponent().sizeDelta.y > sizeY ? 0 : -sizeY + transform.parent.GetComponent().sizeDelta.y + GetComponent().spacing); } void Update() {} }