void CreateItemList() { int playerFunds = GetPlayerMoney(); foreach (Item i in itemsForSale) { ShopItemUIEntry uiEntry = GameObject.Instantiate(shopItemUIEntryTemplate, itemsHolder.transform).GetComponent <ShopItemUIEntry>(); uiEntry.Initialize(i); //uiEntry.gameObject.transform.parent = itemsHolder.transform; } }
public void SelectItem(Item item, ShopItemUIEntry uiEntry) { selectedItem = item; itemDescriptionText.text = item.description; // mark the last selected UI entry as not selected so the image stops bouncing if (selectedUIEntry) { selectedUIEntry.isSelected = false; } selectedUIEntry = uiEntry; selectedUIEntry.isSelected = true; buyButton.gameObject.SetActive(item != null); }
void CreateItemList() { foreach (Transform child in itemsHolder.transform) { Destroy(child.gameObject); } int playerFunds = GetPlayerMoney(); foreach (Item i in itemsForSale) { if (i == null) { Debug.LogError("Null Item!"); } else if (i.CanBeBought()) // IF i IS NULL, UNITY CRASHES { ShopItemUIEntry uiEntry = GameObject.Instantiate(shopItemUIEntryTemplate, itemsHolder.transform).GetComponent <ShopItemUIEntry>(); uiEntry.Initialize(i); } //uiEntry.gameObject.transform.parent = itemsHolder.transform; } }