Posting this here as not getting much response in the support forum.
Hi,
After upgrading to Unity 5.3.4 we’re seeing the error “Releasing render texture that is set to be Camera.targetTexture!” whenever we change anything screen related (resolution, vsync, alt+tab, etc).
There’s no stack or useful information whatsoever but it’s obviously obliterating our RenderTextures. This has not happened prior to 5.3.4. So far we’ve worked around it by disabling and screen changes in-game but this is not ideal and does not stop the problem occuring when alt+tabbing.
Could anyone shed some further light or solutions to this problem?
It’s quite frustrating for us and our users.
I ran into something similar, but it was when I first went to 5.0.1. The problem seems to be that you “can” legitimately lose the render texture if you do certain things, but it’s not always consistent. In my case, it was happening when I set V-Sync on or off. I may just have gotten lucky before 5.x.
On this page:
It says:
What I ended up doing was this in an Update():
// If we lose the render texture, recreate it. Can happen when we set V-sync, full screen, etc.
if (!ShipComputer.Instance.RenderTex.IsCreated())
{
ShipComputer.Instance.RenderTex.Create();
_uiCamera.targetTexture = ShipComputer.Instance.RenderTex;
}
In this case, ShipComputer.Instance.RenderTex is the render texture.
I had posted a question a while back about whether or not it’s a good idea to do that check on every frame, but didn’t get a response. It hasn’t seemed to have any adverse effects and did fix the issue.
Yeah I’ve seen this in the documentation but it’s curious how it has been working flawlessly prior to 5.3.4.
We can manage our own render textures fine, but it’s a rather large pain to try and manage other assets that use render textures… What’s more frustrating is the lack of any information accompanying the error.
There’s a few people experiencing this issue and it doesn’t seem like anyone’s getting a response from Unity…
Wow. That’s unexpected. It’s a little bit confusing though, as the docs imply it’s expected behavior. It sure would be nice to get clarification on that. I’d be a bit nervous to remove my check for the render texture getting lost.
Here’s the item from the patch notes:
“Graphics: Fixed some cases of incorrectly “Releasing Render Texture that is set as Camera.targetTexture”, resulting in losing Camera.targetTexture - e.g. in case of device resume after sleep on iOS/Android, context-loss on DirectX or changing Emulation Layer in the Editor.”
Yeah it’s a bit confusing. We made sure we had everything in order on our end, checking our rendertextures, but we were still losing them at random on some context-losses (alt+tab, etc). The checks are definitely still necessary, but before the fix it was dropping them unexpectedly even with the checks. Seems to be fixed now!