void GenerateBlankMap(int mSize)
{
mapSize = mSize;
//Clear any children that may exist
for (int i = 0; i < parent.childCount; i++)
{
Destroy(parent.GetChild(i).gameObject);
}
map = new List<List<Tile>>();
for (int x = 0; x < mapSize; x++)
{
List<Tile> row = new List<Tile>();
for (int y = 0; y < mapSize; y++)
{
//Create a tile set its position,
//Add it to the row list,
//Set tiles parent to be this gameobject
Tile tile = ((GameObject)Instantiate(PrefabHolder.instance.TILE_BASE_PREFAB,
new Vector3(x - Mathf.Floor(mapSize / 2), 0,
-y + Mathf.Floor(mapSize / 2)),
Quaternion.Euler(new Vector3()))).
GetComponent<Tile>();
tile.gridPosition = new Vector2(x, y);
tile.SetType(TileType.Grass);
row.Add(tile);
tile.transform.SetParent(parent);
}
map.Add(row);
}
}
This code works fine in the editor but when I build it out for standalone use its gives a me a null reference exception when it reaches the Instaniate.
Any help on solving this problem would be greatly appreciated.