My bug is that the GetKeyDown doesn’t work as intended, it seems random when its working or not and I have no idea what could be causing the problem. Code:
function Update() {
if (Network.isServer || Network.isClient) {
ShowInGameGUI = true;
} else {
ShowInGameGUI = false
}
if (ShowInventory) {
if (Input.GetKeyDown(KeyCode.Escape)) {
ShowInventory = false;
return;
}
}
if (!ShowInventory) {
if (Holding) {
var Holding = false;
var CurrentHolding = new item();
var CurrentHNumber = -1;
}
}
if (ShowInGameGUI) {
if ( player == null) {
player = GameObject.Find(PlayerPrefs.GetString("Username"));
}
//Show in-game GUI
if (Input.GetButtonDown("Inventory")) {
if (ShowPauseMenu) {
return;
}
ShowInventory = !ShowInventory;
}
if (Input.GetButtonDown("Cancel")) {
if (ShowInventory) {
ShowInventory = false;
return;
}
ShowPauseMenu = !ShowPauseMenu;
}
if (ShowPauseMenu || ShowInventory) {
mouse(false);
//It seems like these lines are making the game unfocus, so each time you toggle the inventory you will need to click on the game again.
Screen.lockCursor = false;
Screen.showCursor = true;
} else {
mouse(true);
Screen.lockCursor = true;
Screen.showCursor = false;
}
}
}
Would the GUI Code help finding the issue?, maybe some overload when calling or something…