How do I do it? I am trying the onClick but cant find a way to do it. Any scripts? My app is due thursday so please answer ASAP
First create a script that will handle the UI text components and import the UI modules by adding the line
using UnityEngine.UI;
Next create a public text variable and a public function to display the UI text
public Text displayText;
public void DisplayText() {
displayText.text = "What ever you want to display";
}
You could also extend this by adding a public string and changing the display line
public string textToDisplay;
displayText.text = "" + textToDisplay;
Then go to the inspector window onto the UI button gameObject. Then click assign the public function you created earlier to the button function call. If there is text you want to hide at the start, go to the script and add the following lines.
void Start() {
displayText.text = "";
}
These code lines are coded in C#, but if you need to have this in JS it should be easy enough to convert