One Texture2D from multiple others

Hi guys!, I’ve been struggling to find a proper way to create a new Texture2D based on multiple others.

The Idea is that I dynamically load up a list of Textures2D form a certain folder (that’s done). so I have this list of textures. What I want to do is to create a new Texture that has every texture on the list in such a way that it has 1 column and X rows where X is the count of the list.

That way I’ll end up having one texture with every texture of the list in 1 column and I can use this to create a particles system.

So the problem is generating this master texture.

Can anybody help me do this?. Thanks!

[88210-untitled.png*_|88210]Hello guys, for those who are following this question, I managed to solve this. It a little tricky though.

I’ll leave you here the method that I use to create a master image. This is, it takes all pngs (you can modify this) files on the parameters path and merge them into one master png inside a folder called “output”.
The png files dont have to be the same width or height, but I recommend them to be.
The resoulting image will be a png with 1 column and X rows. Its heght will be the sum of all the heights and the width will be the larger of them all. [See the pic]

I hope this helps.

using System.Collections.Generic;
using System.Drawing;  

  public static Texture2D MergeImages(string path)
    {
        string[] filesStrings = null;
        List<Image> images = new List<Image>();
        Bitmap outputImage = null;
        Texture2D outputtexture = null;

        if (path != null && path != "" && path != " " && System.IO.Directory.Exists(path))
        {
            filesStrings = System.IO.Directory.GetFiles(path, "*.png");
            Debug.Log(filesStrings.Length);
        }
        if (filesStrings.Length > 0)
        {
            int outputwidth = 0;
            int outputheight = 0;
            foreach (string filestring in filesStrings)
            {
                Image imageToAdd = Image.FromFile(filestring);
                images.Add(imageToAdd);
                outputheight += imageToAdd.Height;
                if (imageToAdd.Width > outputwidth)
                    outputwidth = imageToAdd.Width;
            }
            outputImage = new Bitmap(outputwidth, outputheight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (System.Drawing.Graphics graphics = (System.Drawing.Graphics.FromImage(outputImage)))
            {
                graphics.DrawImage(images[0], new Rectangle(new Point(), images[0].Size),
                    new Rectangle(new Point(), images[0].Size), GraphicsUnit.Pixel);
            }
            int heightAcum = images[0].Height;
            for (int i = 1; i < images.Count; i++)
            {
                using (System.Drawing.Graphics graphics = (System.Drawing.Graphics.FromImage(outputImage)))
                {
                    graphics.DrawImage(images_, new Rectangle(new Point(0, heightAcum), images*.Size),*_

new Rectangle(new Point(), images*.Size), GraphicsUnit.Pixel);*
}
heightAcum += images*.Height;*
}
path = path + “/Output”;
if (System.IO.Directory.Exists(path))
{
System.IO.Directory.Delete(path, true);
System.IO.Directory.CreateDirectory(path);
}
else
{
System.IO.Directory.CreateDirectory(path);
}
outputImage.Save(path + “/particlesMerge.png”, System.Drawing.Imaging.ImageFormat.Png);

outputtexture = LoadTexture(path)[0];

}

return outputtexture;
}
_*