public void Open() { states = ShopStates.open; playerInv.ActivateInventory(); shop.SetActive(true); #region Logic foreach (ItemData items in shopInventory) { selectedItem = items; GameObject itemSlot = Instantiate(shopPrefab, shopSlotParent); Button itemButton = itemSlot.GetComponent <Button>(); selectedItem.button = itemButton; itemButton.onClick.AddListener(() => DisplayShopInventory(items)); ShopSlot shopSlot = itemSlot.GetComponent <ShopSlot>(); Image image = shopSlot.image; if (image != null) { image.sprite = items.Icon; } } #endregion }