inventory wont open

ok, another quick question i have been trying for ages but i cant seem to script a window and button grid to open when the player presses “B” as like an inventory so the grid needs to be in front of the window.

Thanks!

So… something like this (c#)?

void Update()
	{
		if (Input.GetKeyDown(KeyCode.B))
			_showInventoryWindow = !_showInventoryWindow;
	}

	void OnGUI()
	{
		if (_showInventoryWindow)
			GUI.Window(_inventoryID, _inventoryWindowRect, InventoryWindow, _inventoryWindowTitle);
	}

	void InventoryWindow(int id)
	{
		//button grid code here
	}