Game Development Reference
In-Depth Information
Screen.height - 40 - inventoryWindowSize.y,
inventoryWindowSize.x,
inventoryWindowSize.y);
}
Then, in an OnGUI function, we will draw a button to open the inventory (this could in-
stead be mapped to a key if you wish or both), and if the inventory is to be displayed, we
will draw a custom window using the following code:
void OnGUI()
{
if (GUI.Button(
new Rect(
Screen.width - 40,
Screen.height - 40,
40,
40),
"INV"))
{
displayInventory = !displayInventory;
}
if (displayInventory)
{
inventoryWindowRect = GUI.Window(
0,
inventoryWindowRect,
DisplayInventoryWindow,
"Inventory");
inventoryWindowSize = new Vector2(
inventoryWindowRect.width,
inventoryWindowRect.height);
}
}
For the main inventory window, we will use the custom ability of the Unity3D GUI to
draw the window's contents (as opposed to the manual way, we applied it with the naviga-
tion prompt with BeginGroup and EndGroup ). We implement this with a new func-
Search WWH ::




Custom Search