Exemplo n.º 1
0
    public void AddItem(Item item)
    {
        //Debug.Log("AddItem");
        itemList.Add(item);

        if (inventoryUI == null)
        {
            inventoryUI = InventoryUI.instance;
        }

        if (inventoryUI != null)
        {
            inventoryUI.AddItemToUI(item, GetTotalItems() - 1);
        }
        else
        {
            Debug.Log("inventoryUI is null when adding");
        }
    }
Exemplo n.º 2
0
    private void Start()
    {
        inventoryUI = FindObjectOfType <InventoryUI>();
        if (inventoryUI == null)
        {
            Debug.LogError("inventoryUI is null");
        }

        // Add initial items into the bag
        int count = 0;

        foreach (Item item in itemList)
        {
            if (item != null)
            {
                inventoryUI.AddItemToUI(item, count);
                count++;
            }
        }
    }