This is all in Unity using Monodevelop
I declare my array like this
Tile[] Tiles = new Tile[7];
Then I try and loop through and set the elements (though this itself was an attempt to solve this problem) like this
for (int i = 0; i < Tiles.Length; i++)
{
Tiles[i] = new Tile();
}
However the collection is still filled with 7 null objects. I must be missing something simple. I would have thought the initial line of code would suffice.
Entire example:
using UnityEngine;
using System.Collections;
public class Foo : MonoBehaviour
{
Tile[] Tiles = new Tile[7];
// Use this for initialization
void Start ( )
{
for (int i = 0; i < Tiles.Length; i++)
{
Tiles[i] = new Tile();
}
}
}
This is the Tile class
using UnityEngine;
using System.Collections;
public class Tile
{
public Tile[] nonAdjacentTiles = new Tile[6];
public Transform _mesh;
}