I'm trying to make a 2D array of cubes for easy referencing, and I'm using this as my starting place. I tried testing it with integers and it works just fine, but whenever I try to use GameObjects I get a runtime error.
I added this to the MultiDim.cs:
public static GameObject[,] GameObjectArray (int a, int b) {
return new GameObject[a,b];
}
And then I have this in my main tester:
var cube : GameObject;
var x = 2;
var y = 2;
var tiles;
function Start()
{
var i;
var j;
tiles = MultiDim.GameObjectArray(x,y);
for(i = 0; i < y; i++)
for(j = 0; j < x; j++)
{
Instantiate(cube, Vector3(j, 0, i), transform.rotation);
tiles[j,i] = cube;
}
}
But I always get the runtime error: MissingFieldException: Field 'UnityEngine.GameObject[,].' not found;