public void buildMap() { int elevationBound = elevationMax / elevationInterval; for (int x = 0; x < 20; x++) { for (int z = 0; z < 20; z++) { if (gridInfo[x, z] == 0) { Transform newGrid = (Transform)Instantiate(placeHolderTile, TerrainInfo.GridToTranform(x, z), Quaternion.identity); newGrid.SetParent(gameObject.transform); GridInfo newGridInfo = newGrid.GetComponent <GridInfo>(); newGridInfo.x = x; newGridInfo.z = z; newGrid.GetComponent <MeshRenderer>().material.SetFloat("_Metallic", 1f / (float)(indexMax - indexMin) * (float)(elevationInfo[x, z] - indexMin)); newGridInfo.Elevation = elevationInfo[x, z] * elevationInterval; newGridInfo.setAttribute(); } else if (gridInfo[x, z] == 1) { Transform newGrid = (Transform)Instantiate(routeTile, TerrainInfo.GridToTranform(x, z), Quaternion.identity); newGrid.SetParent(gameObject.transform); GridInfo newGridInfo = newGrid.GetComponent <GridInfo>(); newGridInfo.x = x; newGridInfo.z = z; newGridInfo.Elevation = elevationInfo[x, z] * elevationInterval; newGridInfo.setAttribute(); } } } }