void BuildMap() { mapHolder = new GameObject("Map").transform; TileType tileCheck; GameObject toInstantiate; for (int y = 0; y < size_y; y++) { for (int x = 0; x < size_x; x++) { tileCheck = mapData.GetTileTypeAt(x, y); toInstantiate = nullTile; if (tileCheck == TileType.Water) { toInstantiate = waterTiles[Random.Range(0, dirtTiles.GetLength(0))]; } else if (tileCheck == TileType.Dirt) { toInstantiate = dirtTiles[Random.Range(0, dirtTiles.GetLength(0))]; } else if (tileCheck == TileType.Tree) { toInstantiate = treeTiles[Random.Range(0, treeTiles.GetLength(0))]; } GameObject baseinstance = Instantiate(grassTiles[Random.Range(0, grassTiles.GetLength(0))], new Vector3(x * tileSize, y * tileSize, 0f), Quaternion.identity) as GameObject; GameObject instance = Instantiate(toInstantiate, new Vector3(x * tileSize, y * tileSize, 0f), Quaternion.identity) as GameObject; baseinstance.transform.SetParent(mapHolder); instance.transform.SetParent(mapHolder); } } }