private void updatePanelSlots() { int index = 0; foreach (GameObject child in childs) { InventorySlotController slot = child.GetComponent <InventorySlotController>(); slot.item = index < list.Count ? list[index] : null; slot.updateInfo(); index++; } }
private void updatePanelSlots() { int index = 0; foreach (Transform child in inventoryPanel.transform) { InventorySlotController slot = child.GetComponent <InventorySlotController>(); if (index < list.Count) { slot.item = list[index]; } else { slot.item = null; } slot.updateInfo(); index++; } }