using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; [RequireComponent(typeof(TMP_Text))] public class TMP_CopyTextFromParent : MonoBehaviour { TMP_Text parentText; TMP_Text thisText; private void Awake() { parentText = transform.parent.GetComponent(); thisText = GetComponent(); } private void Update() { if (parentText == null) return; thisText.text = parentText.text; } public void OnValidate() { if (parentText == null) parentText = transform.parent.GetComponent(); if(thisText == null) thisText = GetComponent(); if (parentText == null) return; if (thisText == null) return; thisText.text = parentText.text; thisText.fontSizeMin = parentText.fontSizeMin; thisText.fontSizeMax = parentText.fontSizeMax; } }