I
I
Igorxl2018-12-30 14:08:06
C++ / C#
Igorxl, 2018-12-30 14:08:06

Why can't UI elements be hidden in the void OnTriggerEnter2D(Collider2D other) function?

I need to display the text "Game Over" if the tag of the collider the object touches is equal to "GameOver". I wrote the following

if(other.tag == "GameOver")
{
    Debug.Log("GameOver");
    text.SetActive(true);
    // text - пустой объект к которому привязан текст	
}

But the object doesn't appear even though the text "GameOver" appears in the console.
I tried to do the same, only in the Update() function. The object with the text appeared. So what the heck?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Pogrebnyak, 2018-12-30
@S0HardCore

We need all the code and a screenshot of the text object in the editor. Something is turning it back on, most likely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question