What’s the best practice for setting UI (especially Text) fields by script? By that I mean, I know you can set it like this:
public TMP_Text my_text;
void Update(){
my_text.text = 'hello world';
}
However I don’t see that scaling up to more than a dozen or so strings before it becomes a maintenance nightmare.
I considered a dictioary: Dictionary<string, TMP_Text> text_fields; - but that’s not serializable which presents its own set of problems in regards to populating it. The advantage of a dictionary is that the text can then be easily set with a generic method:
void SetText(string key, string new_text){
text_fields[key] = new_text;
}
Is there a better way to do this? How do folks normally do this? Googling around only found tutorials for complete beginners with the first way.
Thanks