TextHeightAdjuster.cs
659 Bytes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextHeightAdjuster : MonoBehaviour {
public RectTransform baseHeight;
public RectTransform substractHeight;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float newHeight = baseHeight.rect.height - substractHeight.rect.height - transform.GetComponentInParent<VerticalLayoutGroup>().spacing;
Rect rect = transform.GetComponent<RectTransform>().rect;
transform.GetComponent<RectTransform>().sizeDelta = new Vector2(rect.width, newHeight);
}
}