Render Texture to Texture2D

Hi i am trying to convert a render texture to texture2d with a function i found on the internet:

Texture2D ToTexture2D(RenderTexture rTex)
    {
        Texture2D tex = new Texture2D(64, 64);
        RenderTexture.active = rTex;
        tex.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0);
        tex.Apply();
        return tex;
    }

But it doesn’t work. It looks like it moves up and to the right on the texture.

The Render Texture is the image called RT.

The output is the image called Output.

Does anyone know how i can fix this?[/code]

7102765--846712--RT.png
7102765--846715--Output.png

I’m guessing it’s a size mismatch? What’s the size of the RT?

In other news, this might be useful: a snippet I have used to runtime convert non-read-write textures to read-write, and it sorta goes through the same mechanisms:

Code in the second reply…

Both the render texture and the the code are set to 64x64.

I don’t really understand how to code you linked works can you please explain how i can use it?

I have now found the solution. I needed this line of code before the function:
cam.Render()