float[,] heightData = new float[xSize + 1, ySize + 1];
for (int x = 0; x <= xSize; x++){
for (int y = 0; y <= ySize; y++){
float noise = Mathf.PerlinNoise(
sampleModifier + (x * refinement),
sampleModifier + (y * refinement));
heightData[x, y] = noise * heightScale;
}
}
Vector3[] vertices = new Vector3[(xSize + 1) * (ySize + 1)];
int vetCount = 0;
for (int y = 0; y <= ySize; y++){
for (int x = 0; x <= xSize; x++){
vertices[vetCount] = new Vector3(x * xScaleFactor,
heightData[x, y], y * yScaleFactor);
vetCount++;
}
}
mesh.vertices = vertices;
int[] triangles = new int[(xSize * ySize) * 6];
int triCont = 0;
int vertIndex = 0;