Quantcast
Channel: Questions in topic: "insert"
Viewing all articles
Browse latest Browse all 99

List Insert() returns Argument is out of range

$
0
0
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?

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>