Show and hide more buttons after clicking different button
Hello, I want to make a button "Play" that after clicking it will show buttons with levels which I can click to play them. Right now I have only implemented playing the level I want by clicking right button, but I can't make them appear and dissapear after clicking the "Play" button. Here's the code, right now it only shows the levels but I can't hide them after clicking the "Play" button again.
public class MainMenu : MonoBehaviour
{
public GameObject levelButtons;
public void Update ()
{
ShowLevelButtons();
}
public void ShowLevelButtons ()
{
if (Input.GetMouseButtonDown(0))
{
levelButtons.SetActive(true);
}
else
{
levelButtons.SetActive(false);
}
}
}
Answer by pcdrive · Jun 11, 2018 at 11:14 AM
Hi @Creedoo,
You can change their size to 0, and this will make them disappear without any side effects. its like
Button.Transform.localScale = Vector3.Zero;
Hmm, I've tried everything but actually never thought about making something like this, thank you, I'll definitely try that
Umm well, it's working but not as I want, I want that if I click the Play button and only that button it shows all levels as the buttons I can click and teleport to them, and when I click the Play button again, those level buttons just dissapear, and I can click the Play button again to make them appear and again click to dissapear and so on and so on, can something like this be achieved ? I'd be very thankful for every tip, advice or code because I literally spend on it like 2 days without any luck :\