R
R
readrain2022-04-18 11:06:01
C++ / C#
readrain, 2022-04-18 11:06:01

How to make text disappear in Unity?

hello, I need the text to disappear after a while. Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Farawa, 2022-04-18
@Farawa

After a while, read this about coroutine, and about color, either turn it off or text.color.a alpha channel

D
dyzg, 2022-04-18
@dyzg

Now I will throw the code, and I advise you to read the documentation.
You create a variable and IEnumerator IdleFarm or your name.

public GameObject названиетвоейпеременной;
IEnumerator IdleFarm()
    {
        // ждем 
        yield return new WaitForSeconds(время в секундах ( если число с плавающей точкой то в конце f) );
        // теккст пропадает.
        названиетвоейпеременной.SetActive(false);
    }

And do not forget to throw the script on the main camera and specify the object you are referring to in the variable
To call the code
StartCoroutine(IdleFarm());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question