I am shaking off my programming rust and screwing around with unity but I am running into a NullReferenceException
during my initialization.
I have a 2d array of integers in a class see the snippet below
public class Map : MonoBehaviour
{
int[,] Tile;
int sizeX;
int sizeY;
void Start()
{
for (int posX = 0; posX != sizeX; posX++)
{
for (int posY = 0; posY != sizeY; posY++)
{
Tile[posX, posY] = new int() 0;
}
}
}
}
the line
Tile[posX,posY] = new int() 0;
keeps throwing null reference, I have tried to initialize it a number of ways and changed my structure to use int containers instead of game objects as i had intended yet I still run into this error.
All my research tells me I need to initialize but in my mind I am! Where have i gone wrong? Apologize in advance if I missed something in my search queries or am wasting anyone's time by posting this question.
Thank You