private PurchaseItem GetItemForWare(Ware ware, List <PurchaseItem> list, RectTransform panel) { foreach (var item in list) { if (item.ware.id == ware.id) { return(item); } } PurchaseItem newItem = AddItem(panel, list); newItem.SetWare(ware, _warehouse); return(newItem); }
private PurchaseItem AddItem(RectTransform parent, List <PurchaseItem> list) { GameObject go = Instantiate(_listItemPrefab) as GameObject; RectTransform gorect = go.GetComponent <RectTransform>(); PurchaseItem uiItem = go.GetComponent <PurchaseItem>(); float yPos = -5 - list.Count * uiItem.height; go.transform.SetParent(parent, false); gorect.anchoredPosition = new Vector2(10, yPos); uiItem.Deselect(); yPos += uiItem.height; list.Add(uiItem); return(uiItem); }