void OnEnable() { gridList = GetComponent <GridList>(); gridList.Init(); if (slots.Count == 0) { for (int i = 0; i < slotTypes.Length; i++) { slots[slotTypes[i]] = gridList.GetElement <ItemSlot>(i); slots[slotTypes[i]].Index = (int)slotTypes[i]; slots[slotTypes[i]].Filter = filterTypes[i]; } } inventory.EquipmentUpdateCallback += Refresh; }
void Refresh() { var itemList = inventory.GetItemList(); for (int i = 0; i < gridList.Count; i++) { ItemSlot slot = gridList.GetElement <ItemSlot>(i); if (i >= itemList.Count) { slot.Item = null; } else { slot.Item = (itemList[i] == Item.NullItem ? null : itemList[i]); } } }