Hey guys! I have another (hopefully) easy question to answer. For some reason, the menu does not open when I press “Escape”, but closes when I press “Escape” and its already open. Anybody know why?
public bool isInMenu;
// Update is called once per frame
void Update ()
{
if(Input.GetKey(KeyCode.Escape) && isInMenu == false && NetworkManager.Instance.MyPlayer.IsAlive == true)
{
isInMenu = true;
Debug.Log("Menu Opened");
}
if(Input.GetKey(KeyCode.Escape) && isInMenu == true && NetworkManager.Instance.MyPlayer.IsAlive == true)
{
isInMenu = false;
Debug.Log("Menu Closed");
}
}
void OnGUI()
{
if(isInMenu == true)
{
InGameMenu();
}
}
void InGameMenu()
{
if(GUI.Button(new Rect(Screen.width * (0.1f/10f),Screen.height * (0.1f/6.3f),Screen.width/2, Screen.height/2), "Disconnect"))
{
Network.Disconnect();
}
}
Works like a charm thank you :) Thank you very much!
– Borzi