Answer the question
In order to leave comments, you need to log in
Unity gives error Array index is out of range?
Unity throws an error array index is out of range.
There are 2 arrays:
public int[] money = { 0, 0, 0 };
public Text[] moneyText = new Text[3];
moneyText[gameMode].text = money[gameMode] + "$";
Answer the question
In order to leave comments, you need to log in
The size of the array is less than the index you are accessing.
If you have these public fields in the MonoBehaviour successor - then I don't care about new - the unit will init what was saved in the object on which the script hangs. And there most likely 0 objects.
Check with the debugger and in the inspector (if MonoBehaviour).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question