1

I'm working on the main menu for the game, where I have options to join or create a room. Under the Create button, I made an Advanced button which will open the advanced panel, giving the user more options, such as room size. I made the correct onclick() event which uses SetActive property of both the main menu panel and the advanced panel.

screenshot

The problem is, that when I click the button, the advanced menu appears but the main menu doesn't hide. I've looked at different tutorials, but they all say to do exactly what I've done.

apaderno
  • 28,547
  • 16
  • 75
  • 90
Rohan Shetty
  • 162
  • 1
  • 13

1 Answers1

1

I don't usually use these build in methods. The best way is to create your own implementation like so:

public GameObject panel; // drop the panel in the editor

public void onAdvancedClicked()
{
   panel.SetActive(!panel.activeSelf); // make it active/inactive with one click
}

The other way to initialize your panel in the script is by adding tag to it and getting it by tag like so in your start method:

panel = GameObject.FindWithTag("panelTag");
Ivan Kaloyanov
  • 1,748
  • 6
  • 18
  • 24
  • And I almost never use the Inspector UI for this (as I frequently want to pass values to my functions!) and end up doing everything through code using `GetComponent – Draco18s no longer trusts SE Sep 02 '18 at 19:48