コード例 #1
0
    // 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;
        }
    }