You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
864 B
20 lines
864 B
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<RectTransform>().sizeDelta.y + GetComponent<VerticalLayoutGroup>().spacing);
|
|
Debug.Log(transform.childCount + "sizeY: "+sizeY);
|
|
GetComponent<RectTransform>().offsetMax = Vector2.zero;
|
|
GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, transform.parent.GetComponent<RectTransform>().sizeDelta.y > sizeY ? 0 : -sizeY + transform.parent.GetComponent<RectTransform>().sizeDelta.y + GetComponent<VerticalLayoutGroup>().spacing);
|
|
}
|
|
|
|
void Update() {}
|
|
}
|
|
|