I
I
iproyt2021-11-21 12:44:29
Unity
iproyt, 2021-11-21 12:44:29

How to make the text on the screen be shown to you on pressing the button in the unity?

I need to make it show text on the screen when you click, please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Davilkus Games, 2021-11-22
@iproyt

Watching what "buttons".
If UI Button, then you can do this:
public void Clicked() {
text.SetActive(true);
}
- it is necessary to bind this method to the button as an event handler.
If this is a 3D button in the game, then this:
void OnMouseDown() {
text.SetActive(true);
}
If the camera rotation in the game is controlled by the mouse, then you need to lock the cursor in the center of the screen (for the 2nd case):
Cursor.lockState = CursorLockMode.Locked;

L
LittleBob, 2021-11-21
@LittleBob

Create a script in whose public method you will activate the button with SetActive(true). Throw the script on some object, and this object in the action of the button. Choose your method and that's it.
This is just one of the ways.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question