using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CreditsBakers : MonoBehaviour { [TextArea] public string allBakers = string.Empty; public string[] allBakersSplit; public List textFields = new List(); public ScrollRect scrollRect; public RectTransform backgroundRect; public float lineSize = 10f; private void Start() { allBakersSplit = allBakers.Split('\n'); for (int i = 0; i < textFields.Count; i++) { textFields[i].text = string.Empty; } int num = 0; for (int j = 0; j < allBakersSplit.Length; j++) { textFields[num].text += allBakersSplit[j]; textFields[num].text += "\n"; num++; if (num == 3) { num = 0; } } float num2 = (float)allBakersSplit.Length / 3f; for (int k = 0; k < textFields.Count; k++) { textFields[k].rectTransform.sizeDelta = new Vector2(textFields[k].rectTransform.sizeDelta.x, lineSize * num2); } backgroundRect.sizeDelta = textFields[0].rectTransform.sizeDelta; } }