void displayInventory() { inventoryArray = new string[inventory.Keys.Count]; string toAdd = ""; int index = 0; foreach (KeyValuePair <string, int> item in inventory) { toAdd = item.Value + " " + item.Key; inventoryArray[index] = toAdd; index += 1; } GUILayout.BeginArea(new Rect(0.0f, Screen.height / 1.4f, Screen.width, 250.0f)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); inventoryGrid = GUILayout.SelectionGrid(inventoryGrid, inventoryArray, 5); //inventory.Keys.Count); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); if (inventoryGrid > -1) { string[] items = inventoryArray[inventoryGrid].Split(); string symbol = items[items.Length - 1]; if (inventory[symbol] > 0) { if (taskManagement.Progress(symbol) == "Done") { usedCompound = symbol; inventory[symbol] += -1; if (usedCompound.Equals("CH" + c4) || usedCompound.Equals("H" + c2 + "SO" + c4) || usedCompound.Equals("CH" + c3 + "CH" + c2 + "OH")) { ToolToggle(); } } } } }