Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been trying to figure out this but with no success . What I am trying to do is to keep the old text while the script adds the new text below the old text.

public GameObject Text_Object;<br />
         private Text textComponent;<br />
 void Start () {<br />
         //gets the text UI Object in canvas component<br />
         textComponent = Text_Object.GetComponent<Text>();<br />
                 textComponent.text = "Hello";<br />
                 Text2();<br />
     }<br />
<br />
 void Text2(){<br />
 textComponent.text = "Hey";<br />
 }


Basically as you can see the first text gets replace with the second text. What I'm trying to do keep the old text while if I press T it prints the new text below the old text and also add a command when they hit D it clears the text new and old text.

What I have tried:

I have tried researching it but found nothing
Posted
Updated 8-Feb-17 4:30am

C#
textComponent.text = textComponent.text + "Hey";
 
Share this answer
 
Richard gave you a solution, but you need to learn JS much deeper.

http://www.w3schools.com/js/default.asp[^]
W3Schools Online Web Tutorials[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900