public void AddItem(ChestInWorld chest) { if (chest != null && chest.itemProps.Count > 0) { ActiveChest = chest; ActiveChest.DestroyEvent += ActiveChestOnDestroy; for (int i = 0; i < chest.itemProps.Count; i++) { m_ItemSlots[i].Item = chest.itemProps[i].item; m_ItemSlots[i].Amount = chest.itemProps[i].amount; } for (int i = chest.itemProps.Count; i < m_ItemSlots.Length; i++) { m_ItemSlots[i].Amount = 0; } Parent.SetActive(true); } else { foreach (var slot in m_ItemSlots) { slot.Amount = 0; } Parent.SetActive(false); } }
private void ActiveChestOnDestroy(ChestInWorld chest) { ActiveChest = null; foreach (var item in m_ItemSlots) { item.Amount = 0; } Parent.SetActive(false); }