G
G
Garenka2022-02-25 00:41:19
C++ / C#
Garenka, 2022-02-25 00:41:19

How to use a button to display one image and hide another alternately in Unity2D?

Displayed two pictures. Created a button next to them. How to make it so that the first time the button is pressed, one picture remains on the screen, and the second is hidden, and the next time the first is hidden, and the second remains on the screen, respectively?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Farawa, 2022-02-25
@Garenka

bool isOpenFirst = true;
public void SwitchImages()
{
isFirstOpen = !isFirstOpen
Go1.setactive(isFirstOpen);
Go2.setactive(!isFirstOpen);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question