Game Development Reference
In-Depth Information
When the showInventory Boolean is true , we show the inventory GUI. We do
this by setting our inventoryRect rectangle variable to a GUI window. The GUI
window will show the inventory window, as well as give it the title "Inventory" .
Running the GUI
Now, to run the window, we need a function that will show the contents of the GUI
window. Add the following function to your script, under the OnGUI function:
void InventoryGUI(int ID)
{
GUILayout.BeginArea(new Rect(0, 50, 400,
350));
GUILayout.BeginHorizontal();
GUILayout.Button(itemCount[0].Value.ToString()
+ " " + invItems[0].name, GUILayout.Height(75));
GUILayout.Button(itemCount[1].Value.ToString()
+ " " + invItems[1].name, GUILayout.Height(75));
GUILayout.Button(itemCount[2].Value.ToString()
+ " " + invItems[2].name, GUILayout.Height(75));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Button(itemCount[3].Value.ToString()
+ " " + invItems[3].name, GUILayout.Height(75));
GUILayout.Button(itemCount[4].Value.ToString()
+ " " + invItems[4].name, GUILayout.Height(75));
GUILayout.Button(itemCount[5].Value.ToString()
+ " " + invItems[5].name, GUILayout.Height(75));
GUILayout.EndHorizontal();
Search WWH ::




Custom Search