Howto render camera into texture while still rendering into scene view?

I’m writing an editor script and I want to include a preview of the current camera while still displaying the main scene view. I can do the preview fine, with a render texture, however when I render into this RT it removes the camera from the main scene preview.

Is there a way to render into a RT while still displaying the camera view in the main scene?

I’m sure I can duplicate the camera and settings to accomplish this, but not sure if an easier way exists.

Any thoughts on how to go about this?

1 Answer

1

Solved by setting the camera target texture to null right after rendering it:

		mainCamera.targetTexture = renderTexture;

        RenderTexture.active = renderTexture; 

		mainCamera.Render();

		screenTexture.ReadPixels( new Rect(0, 0, width , height ), 0, 0 );
		screenTexture.Apply(false);
		
		RenderTexture.active = null;

		mainCamera.targetTexture = null;

Hi @reissgrant could you tell me what is this screen texture?

That is very odd in fact. In the playerLaser class have you tried setting the private int pointsUp variable 0 in the start method? private void Start() { pointsUp = 0; }