public static ListViewItemContainer <TData, TItemDrawer> CreateListViewItem <TData, TItemDrawer>( RectTransform template, RectTransform contentParent, int index, AiukAbsListView <TData, TItemDrawer> m) where TItemDrawer : IListViewItem <TData>, new() { var go = Object.Instantiate(template.gameObject); var newItem = new ListViewItemContainer <TData, TItemDrawer>(go.GetComponent <RectTransform>(), contentParent, index, m); return(newItem); }
//------------------------------------------------------------------------------------------------------------------------ // AddItemToView() //------------------------------------------------------------------------------------------------------------------------ //Adds a new item container to the view, each view can have its way of displaying items protected override void addItemToView(Item item) { GameObject newItemInstance = GameObject.Instantiate(itemPrefab); newItemInstance.transform.SetParent(itemLayoutGroup.transform); newItemInstance.transform.localScale = Vector3.one;//The scale would automatically change in Unity so we set it back to Vector3.one. ListViewItemContainer itemContainer = newItemInstance.GetComponent <ListViewItemContainer>(); Debug.Assert(itemContainer != null); itemContainer.Initialize(item); _itemList.Add(newItemInstance); }
public override void UpdateObservers(ISubject pSubject) { //Separated the SOLD & PURCHASED actions, should a feature implementation in the future apply for one but not for the other. if (pSubject.SubjectState == (int)ShopActions.PURCHASED) { updateItemList(); } if (pSubject.SubjectState == (int)ShopActions.SOLD) { updateItemList(); } if (pSubject.SubjectState == (int)ShopActions.UPGRADED) { GameObject upgradedItem = _itemList[ShopCreator.Instance.inventoryModel.GetSelectedItemIndex()]; ListViewItemContainer itemContainer = upgradedItem.GetComponent <ListViewItemContainer>(); itemContainer.UpdateItemDetailsUI(); } //Whatever happens, always update the money counter. updateMoneyPanel(); }