RenderTexture contents lost on Standalone Window resize

I have a scene in which I use a RenderTexture to keep track of continuous drawing. I have set the build setting to allow the standalone player to be a “Resizable Window”. The issue I’m facing is that the contents of the RenderTexture get lost when a resize occurs. I have been unable to find a pre-resize event so I could copy the contents of the RenderTexture to a Texture2D to use later to refill the RenderTexture after it gets black.

I have looked at this thread but checking for Screen resolution changes is already too late as the RenderTexture gets black at that point. I would require an event prior to this so I can cache the RenderTexture data before it gets corrupted.

Okay, I have solved this.

Here is what I do:

  1. At Update() i monitor the Camera.main.pixelWidth and Height.

  2. At a change, I recreate my RenderTexture to fit into viewport size (using those parameters).

  3. After this is essential to use this stub:

    Screen.SetResolution(Screen.width, Screen.height, Screen.fullScreen)

@sameer.mirza, i hope this helps.