Hi there,
Does TextMeshProUGUI inherit UI.Text? If no, is there any way to use them both in the same method? Common interface maybe?
I’m trying to refer their text field to replace its string dynamically.
At the moment I use solution like one below:
foreach(var go in gos){
var tmPro = go.GetComponent<TextMeshProUGUI>();
var uiText = go.GetComponent<Text>();
if(tmPro == null && uiText == null)
continue;
if (tmPro != null)
tmPro.text = newText;
if (uiText != null)
uiText.text = newText;
}
but it’s pretty ugly, I’d prefer something more elegant