onClick Event for UI Text?

What am I doing wrong? I am trying to get when I click a button (EasterEgg hidden in the game) That is shows text on screen but I can seem to figure it out.



Not sure if you’ve answered your question already, but to make it show or hide every time you click, you could do the following.

Have whatever text you want in the text object already written, then add a script that looks something like this to the button object:

public class TextShowHide : MonoBehaviour {

	public void ShowHideText (UnityEngine.UI.Text text){
		text.gameObject.active = !text.gameObject.active;

If you do this, you can then go to the button’s onClick and choose the the button. Then for the method go to TextShowHide > TextShowHide (Text) and put whatever text object you want this to affect into the field.

When you click the button the text should then show when it’s hidden and hide it when it’s shown.

I hope this helped.