I have a script that has an int array but in unity I get the error “index out of range” and don’t know whats wrong with it
here’s my script
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
public class Inventory : MonoBehaviour {
public Text inventoryText;
int[] counts = new int[8];
void Update () {
inventoryText.text = "Grass:" + counts[0] + "
Dirt:" + counts[1] + "
Stone:" + counts[2] + "
Drysand:" + counts[3] + "
WetSand:" + counts[4] + "
Coal:" + counts[5] + "
Iron:" + counts[6] + "
Gold:" + counts[7] + "
Diamonds:" + counts[8];
}
public void Add (int tileType, int count){
}
}
the arrays the right size( 8 in length)