- Home /
Display the same string in multiple text boxes
I have a script which writes to a text element in my game. It works fine, but I want a different text element on a different part of the screen to display the SAME string.
As far as I can tell, applying the box to my script to write to in the inspector only attaches the one, even if you copy or duplicate them.
I've tried making them prefabs but they change back to standard gameobjects on play. Not sure why.
Thanks,
Show us the code maybe, we need to see how you do it. You should probably approach this with an array and loop over it. They are also assignable in the inspector.
Answer by j4ke · Feb 06, 2020 at 03:02 PM
You can make an array of text elements in your script and make a for loop function to iterate all those array elements to write the text to those elements. Then attach all those text boxes to the same array in the Inspector.