- Home /
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.
Answer by AgentFire · Oct 11, 2015 at 11:13 AM
Okay, I have solved this.
Here is what I do:
At
Update()
i monitor the Camera.main.pixelWidth and Height.At a change, I recreate my RenderTexture to fit into viewport size (using those parameters).
After this is essential to use this stub:
Screen.SetResolution(Screen.width, Screen.height, Screen.fullScreen)
@sameer.mirza, i hope this helps.
@AgentFire Hey, I'm facing this exact problem. How do you recreate the RenderTexture?
Cheers