void RefreshBiomeTexture() { if (biomeTex == null || biomeTex.width != mapResolution) { biomeTex = new Texture2D(mapResolution, mapResolution, TextureFormat.ARGB32, false); } int width = biomeTex.width; int height = biomeTex.height; Color[] colors = new Color[width * height]; if (env == null || tg == null) { colors.Fill <Color> (new Color(0, 0.5f, 0, 0.5f)); } else { env.SetBiomeDefaultColors(false); colors.Fill <Color> (Misc.colorTransparent); // reset biome stats for (int k = 0; k < world.biomes.Length; k++) { if (world.biomes [k] != null) { world.biomes [k].biomeMapOccurrences = 0; } } // draw biome colors for (int j = 0; j < height; j++) { float z = (maxZ - minZ) * (float)j / height + minZ; int jj = j * width; for (int k = 0; k < width; k++) { float x = (maxX - minX) * (float)k / width + minX; HeightMapInfo info = env.GetTerrainInfo(x, z); if (info.groundLevel <= tg.waterLevel) { colors [jj + k] = waterColor; } else { BiomeDefinition biome = info.biome; if (biome == null) { continue; } biome.biomeMapOccurrences++; if (biome.showInBiomeMap) { colors [jj + k] = biome.biomeMapColor; } } } } int gridCount = (int)((maxZ - minZ) / gridStep); Color gridColor = new Color(64, 64, 64, 0.2f); // draw horizontal grid lines for (int j = 0; j <= gridCount; j++) { int y = (int)((height - 1f) * j / gridCount); for (int k = 0; k < width; k++) { colors [y * width + k] = gridColor; } } gridCount = (int)((maxX - minX) / gridStep); // draw vertical grid lines for (int j = 0; j <= gridCount; j++) { int x = (int)((width - 1f) * j / gridCount); for (int k = 0; k < height; k++) { colors [k * width + x] = gridColor; } } } biomeTex.SetPixels(colors); biomeTex.Apply(); }