// Update is called once per frame void Update() { // update blockAmounts array for (int i = 0; i < 4; i++) { inventoryItems[i] = new InventoryItemScript(); inventoryItems[i].itemCount = playerScript.blockCounts[i]; inventoryItems[i].itemName = blockName[i]; inventoryItems[i].itemImage = blockImage[i]; } // if the 0 key is pressed if (Input.GetKeyDown(KeyCode.Alpha0)) { if (invPanelOpen) { invPanelOpen = false; // if the inventory panel is open, close it inventoryPanel.SetActive(false); // freeze the cursor voxChunk.LockCursor(); } else { invPanelOpen = true; // if the inventory panel is closed, open it inventoryPanel.SetActive(true); SortByAmount(); searchBar.text = ""; // unfreeze the cursor voxChunk.UnlockCursor(); } } // if there are no panels open if (!invPanelOpen && !voxChunk.panelOpen) { // allow the player to move fpscript.m_RunSpeed = 10; fpscript.m_WalkSpeed = 5; } // if either panel is open else if (invPanelOpen || voxChunk.panelOpen) { // freeze the player fpscript.m_RunSpeed = 0; fpscript.m_WalkSpeed = 0; } if (invPanelOpen) { // search input search = searchBar.text; SearchByName(search.ToLower()); } }