public void RefreshItems() { _itemPrefabList.SetActiveForAll(false); List <ItemDisplayInterface> sorted = new List <ItemDisplayInterface>(); List <Item> availableItems = DataManager.Instance.GetItemsAvailable(_EquipType, _ITEM_FILTER_TYPE); Func <Item, int> statsFunc = DataManager.Instance.GetItemsStatsFunc(_ITEM_FILTER_TYPE); foreach (var item in availableItems) { GameObject itemGO = _itemPrefabList.GetOrCreate(ItemPrefab); Button itemBtn = itemGO.GetComponent <Button>(); ItemDisplayInterface itemDisplay = itemGO.GetComponent <ItemDisplayInterface>(); RectTransform itemRect = itemGO.GetRect(); itemDisplay.LoadItem(item, Btn_ShowItem, _heroInterface); itemRect.SetParent(ItemContainer); itemRect.localScale = Vector3.one; itemRect.anchoredPosition = Vector2.zero; itemRect.sizeDelta = new Vector2(1f, 1f); itemDisplay.StatsInfo.SetActive(true); itemDisplay.txtStatsInfo.text = item.isIdentified && statsFunc != null?statsFunc(item).ToString() : "..."; itemGO.transform.SetAsLastSibling(); } }
// Use this for initialization void Start() { btnClose.onClick.AddListener(Btn_OnClose); btnIdentify.onClick.AddListener(Btn_OnIdentify); selector.gameObject.SetActive(false); _items = new List <ItemDisplayInterface>(); if (!dataMan || dataMan.allItemsList == null) { traceError("Only running demo, dataMan | dataMan.allItemsList is not initialized."); return; } int scrolls = CurrencyTypes.SCROLLS_IDENTIFY.GetAmount(); txtIdentify.text = BUTTON_LABEL.Format2(scrolls); var itemDatas = dataMan.allItemsList.FindAll(item => !item.isIdentified && !item.isResearched); foreach (Item itemData in itemDatas) { ItemDisplayInterface itemContainer = grid.AddClone(itemTemplate); itemContainer.transform.localScale = Vector2.one; itemContainer.LoadItem(itemData, Btn_ItemClicked, null); _items.Add(itemContainer); } noItemsToSelect.SetActive(false); itemTemplate.gameObject.SetActive(false); bool isNoItems = itemDatas.Count == 0; bool isNoScrolls = scrolls == 0; if (isNoItems) { noItemsToSelect.SetActive(true); } if (isNoItems || isNoScrolls) { btnIdentify.interactable = false; } }