void CreateItemObj(Item item, int amount, ItemSlot slot) { ItemObj obj = Instantiate <ItemObj>(itemPrefab, slot.transform); obj.UpdateItem(item, amount); obj.SetRaycaster(raycaster); slot.SetItem(obj); if (!lookup.ContainsKey(item)) { lookup.Add(item, new List <ItemObj>()); } lookup[item].Add(obj); lookup[item].Sort(comparer); }
public void AddItems(List <ItemAmount> rewards) { if (slots == null) { slots = new List <ItemSlot>(); } if (removeSlot == null) { removeSlot = new RemoveSlotEvent(); removeSlot.AddListener(CheckSlots); } foreach (ItemAmount item in rewards) { RewardSlot slot = Instantiate <RewardSlot>(slotPrefab, itemList); slot.SetIndex(slots.Count); slot.AddCallBack(removeSlot); slots.Add(slot); ItemObj obj = Instantiate <ItemObj>(objPrefab); obj.UpdateItem(item); obj.SetRaycaster(raycast); slot.SetItem(obj); } }