ive got this class it has one 2dArray and when im trying to fill it im getting the error NullReferenceException: Object reference not set to an instance of an object AdminGrid.FullNot(Int32 Row, Int32 Column, Int32 Full, System.String PieceName)
public class AdminGrid : MonoBehaviour {
public int numRows;
public int numColumns;
private int[,] ArrayGrid;
// Use this for initialization
void Init() {
numColumns = 6;
numRows = 6;
ArrayGrid = new int[numRows,numColumns];
for(int y = 0;y < numRows;y++)
{
for(int x = 0;x < numColumns;x++)
{
ArrayGrid[y,x] = 0;
}
}
}
public void FullNot(int Row,int Column,int Full,string PieceName)
{
ArrayGrid[Row,Column] = 1;//Error is here
}
public int WhatsonGrid(int Row,int Col)
{
return ArrayGrid[Row,Col];
}
}
Any idea why this is happening? as you can see my array is filled with 0s i thought that would fix this but it seems like not,also i made sure the values are inside the array meaning the max for columns and rows are 5,5
im using the engine Unity so Init //actually called start
it gets called when the game starts as a rule thats why im pretty sure it is called