public void Load()
 {
     ThreadedDataRequester.RequestData(
         () => HeightMapGenerator.GenerateHeightMap(
             meshSettings.NumVertsPerLine, meshSettings.NumVertsPerLine,
             heightMapSettings, sampleCenter),
         OnHeightMapReceived);
 }
        public void DrawMapInEditor()
        {
            if (colorMap)
            {
                textureData.ApplyToColorMaterial(colorTerrainMaterial);
                textureData.UpdateMeshHeights(colorTerrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
                meshRenderer.sharedMaterial = colorTerrainMaterial;
            }
            else
            {
                textureData.ApplyToTextureMaterial(textureTerrainMaterial);
                textureData.UpdateMeshHeights(textureTerrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
                meshRenderer.sharedMaterial = textureTerrainMaterial;
            }

            HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(
                meshSettings.NumVertsPerLine, meshSettings.NumVertsPerLine, heightMapSettings, Vector2.zero);

            switch (drawMode)
            {
            case DrawMode.Noise:
                DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
                break;

            case DrawMode.FalloffMap:
                DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(
                                                                      FalloffGenerator.GenerateFalloffMap(meshSettings.NumVertsPerLine, heightMapSettings.falloffCurve),
                                                                      0, 1)));
                break;

            case DrawMode.Mesh:
                DrawMesh(MeshGenerator.GenerateTerrainMesh(
                             heightMap.values, meshSettings, editorPreviewLOD));
                break;
            }
        }