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.
 
 
 
 
 

21 lines
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Scrollable : MonoBehaviour {
public const float size = 35f;
void Start() {
var sizeY = -(transform.childCount-1) * (transform.GetChild(0).GetComponent<RectTransform>().sizeDelta.y + GetComponent<VerticalLayoutGroup>().spacing);
Debug.Log(transform.parent.GetComponent<RectTransform>().sizeDelta.y + " -- " + (-sizeY));
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));
int i = 1;
foreach(Transform child in transform) {
if(i % 2 == 1)
child.GetComponent<RawImage>().color = new Color(child.GetComponent<RawImage>().color.r, child.GetComponent<RawImage>().color.g, child.GetComponent<RawImage>().color.b, child.GetComponent<RawImage>().color.a / 2);
i++;
}
}
void Update() {}
}