I have a need in my current project to combine multiple textures into one. I’m not sure the most practical and memory efficient way to go about this. I’ve considered many options including using a List and then do something like:
Texture2D[,] textureGrid = new Texture2D[numberOfHorizontalTextures, numberofVerticalTextures];
Then go through each texture horizontally and use GetData(Color c) to get the pixels, add them to a destination texture using SetData, move down to the next vertical row and start again. This, unfortunattely, means that with each iteration along the horizontal, GetData is called on each texture over and over again. I’ve also considered using GetData in a Dictionary, like this:
Dictionary<Texture2D, Color> textureDictionary = new Dictionary<Texture2D, Color>
This, however, is essentially an array of arrays and textures, which would get memory heavy in almost no time. I can’t just iterate through a List, since each texture in the combined texture needs a specific X and Y position in order to make the desired image.
Am I overthinking this? Is there a quick and less memory intensive way of doing this that I’m just not aware of?