private void FillPlayerInventoryPanel() { //Get the player's inventory UIControllerScript uic = otherCanvas.GetComponent <UIControllerScript>(); List <Placeable> inventoryData = uic.getInventoryData(); List <int> inventoryCount = uic.getInventoryCount(); //Get the panel to add to RectTransform pip = GameObject.Find("playerInventoryPanel").GetComponent <RectTransform>(); for (int ii = 0; ii < fpc.inventorySize; ii++) { //Add item to player inventory rect //Build the slot regardless of whether or not it will be empty GameObject slotObject = Instantiate(playerInventorySlotPrefab, pip); MenuSlot slot = slotObject.GetComponent <MenuSlot>(); slot.slotIndex = ii; //Add an item to the slot if it shouldn't be empty if (inventoryData[ii] != null && inventoryCount[ii] > 0) { //Add the slot item to the slot GameObject itemObject = Instantiate(slotItemPrefab, slot.GetComponent <RectTransform>()); MenuSlotItem item = itemObject.GetComponent <MenuSlotItem>(); item.setID(inventoryData[ii].id, inventoryData[ii].isFlower); item.setCount(inventoryCount[ii]); slot.GetComponent <MenuSlot>().setItem(item); } } }