Text displaying on screen for 5 sec. after clicking on a button

Hello, im a beginner in programming and im making an easy 2D game.
Im looking for someone to help me with one thing…
I want to display a text on screen for 5 sec. after clicking a button, and I don’t know how to do so :frowning:
For any help, thank you.
[C#]

Which part do you need help with?
If your answer is more than 1 thing, you should really check out this section: Learn

Even if it’s just 1 thing, that section would probably still help. There are tutorials, small games/projects, sections on learning the UI, scripts, live training, etc… :slight_smile:

1 Like

The only thing i need help with is just the time because I’ve already created the script that will show up the text on screen after clicking the button, but it’s not disappearing after 5 sec what I want to happen.
I know it’s the basic stuff but I just don’t know how to do so :confused:

Well, for something so simple, I’d write a method:

void HideText() {
   textVariable.enabled = false; // thi s would just be the Text component. You could disable the whole game object if you wanted to, instead. or destroy it.. depends what you want :)
  }

//and in Start():
void Start() {
  Invoke("HideText", 5);
  }

The other option that comes to mind would be a simple Coroutine:

void Start() {
  StartCoroutine(HideText());
  }
IEnumerator HideText() {
   yield return new WaitForSeconds(5);
   textVariable.enabled = false;
   }
1 Like

It helped me a lot, thank you :slight_smile:

You’re welcome, man. :slight_smile:

1 Like