Wrong RenderToTexture from ReadPixels () ?

I am trying to capture a RenderToTexture to a texture.

My scene setup for tests are quite simple :

  • a main camera.
  • a secondary camera with a RenderToTexture.
  • a plane to preview the RenderToTexture in realtime.
  • another plane to preview the final texture (capture from RenderToTexture).
  • a button to launch the capture.

The renderToTexture to work well : Preview on the first plane is good.

But once I launch the capture, it seems to copie is the complete Game View (yes the unity’s Game View O_o)…

The template code I am using to get the render to texture looks like the following :

finalTexture.ReadPixels(myRect, 0, 0);

The part I do not understand is how it is supposed to find the right renderToTexture if I had more than one?
Maybe the reason I do not obtain the right result…

Does someone know more about it?:face_with_spiral_eyes:

Thanks a lot!!

Alright sorry, I made 2 new friends :

camera.Render()
RenderTexture.active

It works perfectly now :slight_smile: