public override void CreateMenu(RectTransform Parent) { Entity_Player player = Entity_Player.Main; Vector2 startPoint = new Vector2(0, -Parent.rect.height * 0.5f); // Add callback mInventory = player.mInventory; mInventory.mChangeEvent += OnInventoryChange; // Create player hotbar uint width = Entity_Player.InventoryWidth; uint height = Entity_Player.InventoryHeight; float halfWidth = width * 0.5f; mInventorySlots = new InventorySlotUI[width, height]; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { // Inventory slot InventorySlotUI slot = Instantiate(InventorySlotUI.DefaultSlot, Parent); slot.name = "Slot " + x + "," + y; slot.Construct(mInventory, x, y); // Make sure inventory is in order from top-left to bottom-right int displayY = y; if (y != 0) { displayY = (int)height - y; } RectTransform slotRect = slot.GetComponent <RectTransform>(); slotRect.localPosition = startPoint + new Vector2(slotRect.rect.width * (x - halfWidth + 0.5f), slotRect.rect.height * (displayY + 0.5f)); // Set hotbar different colour if (y != 0) { slot.SetColour(Color.grey); } // Set contents slot.SetItem(player.mInventory.Get(x, y)); mInventorySlots[x, y] = slot; } } }