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.

4

1 回答 1

1

我通常不使用这些内置方法。最好的方法是创建自己的实现,如下所示:

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

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

在脚本中初始化你的另一种方法panel是向它添加标签并通过标签获取它,就像在你的 start 方法中一样:

panel = GameObject.FindWithTag("panelTag");
于 2018-09-01T19:29:15.307 回答