using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TextScale : MonoBehaviour { private Text text; private RectTransform rectTrans; private void OnEnable() { text = GetComponent(); rectTrans = transform.GetComponent(); } public void OnTextChange(string v) { Debug.Log(gameObject.name + text.text.Length); text.text = ((v.Length >= 0) ? "" : "") + (v).ToString() + ""; rectTrans.sizeDelta = new Vector2( rectTrans.sizeDelta.x, text.text.Length * 1.8f); } }