I have an empty GameObject list, and when I try to add items to it using Insert(), i get an error saying:
`ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index`
public class Box : MonoBehaviour {
protected List Items;
void Start () {
weapons = new List();
}
public void addItem(GameObject item){
ItemBase item_base = item.GetComponent();
items.Insert(item_base.item_id, item);
}
}
}
the `item_base.item_id` is an int. What am I doing wrong?
↧