Good day, I'm trying to generate a tilemap, my current setup is a base tileset, and a few overlays for the different biomes / terrain heights. In my code, I generate each biome's tileset, based off of the base tileset, multiplied by the biome's overlay. However, as you can see in he image, it's reusing the first biome's overlay for all biomes.
Here's my code:
for (int i = 0; i < biomes.Length; i++)
{
StatusText.text = "Generating Biome["+i+"] Tileset...";
biomes[i].TileSet = new Sprite[_tileSet.Length]; // Creates the sprite array for the tileset of biome [i].
Color[] b = biomes[i].Overlay.texture.GetPixels(); // Gets biome[i] overlay in a color array.
for (int x = 0; x < _tileSet.Length; x++)
{
Debug.Log(biomes[i].Name);
Debug.Log(biomes[i].Overlay);
Color[] a = _tileSet[x].GetPixels(); // Get's base tile [x] in tileset pixels.
for (int j = 0; j < a.Length; j++)
{
a[j] *= b[j]; // Multiplies each pixel of the copy of base tile in the new color array with the overlay of biome[i].
}
Texture2D tex = new Texture2D(8, 8);
tex.SetPixels(a);
tex.filterMode = FilterMode.Point;
tex.Apply();
biomes[i].TileSet[x] = Sprite.Create(tex, new Rect(0, 0, 8, 8), new Vector2(4, 4), 8); // Creates sprite from generated texture.
}
}