예제 #1
0
    public void InventoryClicked()
    {
        /*inventoryButton.gameObject.SetActive(false);
         * statusButton.gameObject.SetActive(false);
         * equipmentButton.gameObject.SetActive(false);
         * saveButton.gameObject.SetActive(false);
         * optionsButton.gameObject.SetActive(false);
         */
        if (currentTab == 1)
        {
            return;
        }
        Debug.Log(inventory.items.Count);

        //int x_offset = 0;
        //int y_offset = 0;
        int i = 0;

        foreach (KeyValuePair <string, Item> entry in inventory.items)
        {
            Item       item   = entry.Value;
            ItemButton button = Instantiate(itemButton, Vector3.zero, Quaternion.identity);
            button.SetItem(item);
            button.SetPlayer(player);
            button.panel = window;
            //button.SetDropdownParent(dropdownLayer.transform);
            //Button itemButton;
            button.transform.SetParent(scrollContent.transform, false);

            /*RectTransform buttonRT = (RectTransform)button.transform;
             * RectTransform itemPanelRT = (RectTransform)itemPanel.transform;
             * float w = buttonRT.rect.width;
             * float h = buttonRT.rect.height;
             * float left = itemPanelRT.rect.xMin + x_offset * w;
             * float top = itemPanelRT.rect.yMax - y_offset * h;
             * Debug.Log(left);
             * Debug.Log(top);
             * buttonRT.offsetMin = new Vector2(left, top-h);
             * buttonRT.offsetMax = new Vector2(left+w, top);*/
            button.itemName.text = entry.Key + " x" + item.count;

            /*if(x_offset == 0){
             *      x_offset = 1;
             * }
             * else{
             *      x_offset = 0;
             ++y_offset;
             * }*/
            //itemButtons[i].gameObject.SetActive(true);
            itemButton.menu  = this;
            itemButton.index = i;
            itemButtons.Add(button);
            ++i;
        }
        itemPanel.gameObject.SetActive(true);
        backButton.gameObject.SetActive(true);
        itemButtons[0].button.Select();
        currentTab = 1;
    }