Setting pixels in an area of a texture?

I’m creating a texture atlas by adding tiles to a specific area of a texture by doing this:

void AddTileToTexture(Texture2D texture, Texture2D tile, Vector2 position){
        for (int x = 0; x < tile.width; x++) {
            for (int y = 0; y < tile.height; y++) {
                texture.SetPixel ((int)position.x + x, (int)position.y + y, tile.GetPixel (x, y));
            }
        }
    }

Using this makes the chunk take a while to load from all the looping, but i would prefer it to generate quicker, is there any built in function such as texture.SetPixels () that let’s my put a texture in a bigger texture to create a texture atlas.

You could use SetPixels which is a lot faster - either by doing a line at a time or a whole block.

e.g.

public void SetPixels(int x, int y, int blockWidth, int blockHeight, Color[] colors, int miplevel = 0);

If you want it to be really fast you could set up a render texture and render the tiles into it by using the OpenGL commands or by creating a mesh. You would then grab the render texture and save it out as a texture.

When i looked in the documentation i saw the top which said “public void SetPixels(Color[ ] colors, int miplevel = 0);” and assumed it could only set a whole texture, i guess i should have looked through the whole thing lol thanks for pointing that out.