- Home /
Is It Possible to Render the same Data to 2 Different UI Text Objects?
Is it possible that lets say I have two different UI text objects on two different canvas panels. Can I render the same information to both UI text objects using only one method?
if (sysHour >= 18 && sysHour <= 24) {
MessageCentreText.text = "GOOD EVENING";
//Debug.Log ("Good Evening!");
}
Answer by SterlingSoftworks · Jan 21, 2016 at 07:20 PM
Yes, that is entirely possible.. Did you even try to do that before coming here..? ._.
@SterlingSoftworks, Yeah I tried experimenting with a few things, spent a good deal of time looking for any examples of how to do that, obviously I'm asking because I found a s$$anonymous$$$$anonymous$$g load of bubcas ;) Next silly question ;)
Hey, some people come here for some questions that have been asked 20x so I'm just making sure you actually TRIED something before asking. Didn't want to come off as rude with that, but I'm sure it was xD
Why don't you just create an instance of the other UI text (by either a public text variable or a private and you find it via GameObject.Findblahblahblah) you're trying to change within that script and set it there too?
Another way would be to create a new script specific to the secondary UI text and create a public UI text variable called copyText.. Drag the UI you want it to copy to that in the inspector, and then in OnGUI (or whatever you'd like to use) just set the text element = to copyText.text. Those two ways should work. :D
@SterlingSoftworks, Yup it works, a lot of my wasted time was trying to cram it into one line I tried && + || even something like: timeText2.text, timerText3 = hh + ":" + mm + ":" + ss; It seemed logical to me but all I got was errors and some quality time with the Headache tablets bottle lol