I’m trying to create a crafting system but I need to know how many of each item I have it my list (aka inventory). For some reason this code is not working:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Crafting : MonoBehaviour {
private Inventory i;
public GameObject Stick;
private int sticksNum = 0;
private int stones = 0;
// Use this for initialization
void Start () {
i = gameObject.GetComponent<Inventory> ();
}
public void makeStoneAxe() {
foreach (Stick in i.getItemsInList()) {
sticksNum += 1;
}
}
// Update is called once per frame
void Update () {
Debug.Log (sticksNum);
}
}