Пример #1
0
    public void ItemAdded(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(itemContainer, scrollViewContent);

        emptyItem.transform.localPosition = new Vector3(1, 1, 1);
        emptyItem.SetItem(item);
        // emptyItem.transform.SetParent(scrollViewContent);
        scrollViewContent.sizeDelta = new Vector2(scrollViewContent.rect.width, scrollViewContent.rect.height + itemContainer.GetComponent <RectTransform>().rect.height);
        emptyItem.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
    }
 public void ItemAdded(Item item)
 {
     if (item.Stackable && CheckIfItemIsInInventory(item))
     {
         for (int i = 0; i < itemUIList.Count; i++)
         {
             if (itemUIList[i].item == item)
             {
                 itemUIList[i].UpdateCount();
             }
         }
     }
     else if (!item.Stackable || !CheckIfItemIsInInventory(item))
     {
         InventoryUIItem emptyItem = Instantiate(ItemContainer);
         emptyItem.SetItem(item);
         itemUIList.Add(emptyItem);
         emptyItem.transform.SetParent(itemHolder);
         emptyItem.transform.localScale = new Vector3(1f, 1f, 1f);
         inventoryButtons.Add(emptyItem.GetComponent <Button>());
     }
 }