I don’t understand why this does not work:
Vector3 pos = new Vector3(x,0,y);
TerrainTiles.Add(Instantiate(Resources.Load("Prefabs/TerrainTile"), pos, Quaternion.identity) as TerrainTile);
Debug.Log("List items: " + TerrainTiles.Count.ToString());
TerrainTiles[TerrainTiles.Count - 1].xPosition = x;
Running the debug log shows that the list items are being created but when I try to reference any of them as in the last line of code above I am getting a NullReferenceException.