public void GenerateMap() { float[,] noiseMap = PerlinNoise.NoiseMap( mapWidth, mapHeight, seed, noiseScale, octaves, amplitude, frequency, offset); Color[] colorMode = new Color[mapWidth * mapHeight]; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { float currentHeight = noiseMap [x, y]; for (int i = 0; i < heights.Length; i++) { if (currentHeight <= heights [i].height) { colorMode [y * mapWidth + x] = heights [i].colour; break; } } } } DisplayNoise display = FindObjectOfType <DisplayNoise> (); if (displayMode == DisplayMode.NoiseMap) { display.DrawTexture(Textures.HeightMapTexture(noiseMap)); } else if (displayMode == DisplayMode.ColourMap) { display.DrawTexture(Textures.ColorTexture( colorMode, mapWidth, mapHeight )); } }